Page 1 of 1

mogrify -clone error help

Posted: 2018-02-01T14:26:04-07:00
by howtaebatch
Hi all,

(Running windows 10, cmd line, Win32 dynamic at 16 bits-per-pixel component, ImageMagick-7.0.7-22-Q16-x86-dll.exe)

The following code works but I'm trying (with little success) to run it through multiple files.

magick "filepath.jpg"^
( -clone 0 -crop 485x181+847+969 -resize 485x181! -repage 490x362+0+0 )^
( -clone 0 -crop 485x111x2307+1574 -resize 485x111! -repage 490x362+0+181 )^
-delete 0 -flatten output.jpg

Research suggests that mogrify doesn't work with -clone? Apparently a windows batch for loop is my best bet but I have little experience and would greatly appreciate any suggestions or guidance?

Cheers!

Re: mogrify -clone error help

Posted: 2018-02-01T18:04:00-07:00
by fmw42
I do not think you can use mogrify with parenthesis and clones. You will likely have to write a script loop over each of the images you want to process.

Re: mogrify -clone error help

Posted: 2018-02-02T01:45:39-07:00
by howtaebatch
Hi! Thanks for the quick response.
fmw42 wrote: 2018-02-01T18:04:00-07:00 You will likely have to write a script loop over each of the images you want to process.
I need the code to run through hundreds of images all with exactly the same coordinates.
Is there any way to automate this process?

Re: mogrify -clone error help

Posted: 2018-02-02T04:55:44-07:00
by snibgo
What's the problem? As Fred says, put it in a loop, eg in a BAT script:

Code: Select all

for %%F in (*.jpg) do magick ^
  "%%F" ^
  ( -clone 0 -crop 485x181+847+969 -resize 485x181! -repage 490x362+0+0 ) ^
  ( -clone 0 -crop 485x111x2307+1574 -resize 485x111! -repage 490x362+0+181 ) ^
  -delete 0 -flatten "newdir\%%F"

Re: mogrify -clone error help

Posted: 2018-02-02T17:00:55-07:00
by howtaebatch
Hi

Commands don't seem to be executing now? I'm sure that I'm referencing the correct path. Changed the file extension and still no luck.

magick: unable to open image 'C:\Users\Travel\Desktop\ocr_certs\Cert\Mnth1.tiff(': No such file or directory @ error/blob.c/OpenBlob/3335.
magick: unable to open module file 'C:\Program Files\ImageMagick-7.0.7-Q16\modules\coders\IM_MOD_RL_TIFF(_.dll': No such file or directory @ warning/module.c/GetMagickModulePath/675.
magick: no decode delegate for this image format `TIFF(' @ error/constitute.c/ReadImage/509.

I've uninstalled and reinstalled and rebooted without success.

Thanks.

Re: mogrify -clone error help

Posted: 2018-02-02T17:06:17-07:00
by fmw42
Is libtif installed. That is does

magick -version

list tiff in the Delegates section

What was your exact command where it failed?

Re: mogrify -clone error help

Posted: 2018-02-02T17:51:40-07:00
by howtaebatch
yes tiff is listed in the delegates:

Version: ImageMagick 7.0.7-22 Q16 x86 2018-01-22 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype gslib jng jp2 jpeg lcms lqr openexr pangocairo png ps raw rsvg tiff webp xml zlib

-----------------------------------------------------------------------------

The command is much the same as above (tried with both jpg and tiff formats): my exact command in cmd line (which executed perfectly yesterday):

C:\Users\Travel\Desktop\ocr_certs\Cert>magick "C:\Users\Travel\Desktop\ocr_certs\Cert\Mnth1.tiff"^
More? ( -clone 0 -crop 485x181+847+969 -resize 485x181! -repage 490x362+0+0 )^
More? ( -clone 0 -crop 485x111x2307+1574 -resize 485x111! -repage 490x362+0+181 )^
More? -delete 0 -flatten output.tiff

The response is:

magick: unable to open image 'C:\Users\Travel\Desktop\ocr_certs\Cert\Mnth1.tiff(': No such file or directory @ error/blob.c/OpenBlob/3335.
magick: unable to open module file 'C:\Program Files\ImageMagick-7.0.7-Q16\modules\coders\IM_MOD_RL_TIFF(_.dll': No such file or directory @ warning/module.c/GetMagickModulePath/675.
magick: no decode delegate for this image format `TIFF(' @ error/constitute.c/ReadImage/509.

Thanks again guys appreciate the responses.

Re: mogrify -clone error help

Posted: 2018-02-02T19:26:01-07:00
by fmw42
What is "More?" in your command? You need a space before and after parentheses. So the problem is you have )^ and need ) ^.

Try

Code: Select all

C:\Users\Travel\Desktop\ocr_certs\Cert>magick "C:\Users\Travel\Desktop\ocr_certs\Cert\Mnth1.tiff" ^
( -clone 0 -crop 485x181+847+969 -resize 485x181! -repage 490x362+0+0 ) ^
( -clone 0 -crop 485x111x2307+1574 -resize 485x111! -repage 490x362+0+181 ) ^
-delete 0 -flatten output.tiff

Re: mogrify -clone error help

Posted: 2018-02-02T21:00:41-07:00
by snibgo
howtaebatch wrote:magick: unable to open image 'C:\Users\Travel\Desktop\ocr_certs\Cert\Mnth1.tiff('
You should always read error messages carefully. IM told you it was trying to open a file that had "(" at the end of its name.

The command I showed you had a space before each line-continuation "^" at the end of each line, and also had spaces at the start of each line. You removed all these spaces, and that caused the problem.

Re: mogrify -clone error help

Posted: 2018-02-03T08:21:47-07:00
by howtaebatch
Got the command working; Batch file is working too. Thanks for the help guys! Appreciated.