mogrify -clone error help

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
howtaebatch
Posts: 5
Joined: 2018-01-31T16:15:11-07:00
Authentication code: 1152

mogrify -clone error help

Post 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!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: mogrify -clone error help

Post 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.
howtaebatch
Posts: 5
Joined: 2018-01-31T16:15:11-07:00
Authentication code: 1152

Re: mogrify -clone error help

Post 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?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: mogrify -clone error help

Post 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"
snibgo's IM pages: im.snibgo.com
howtaebatch
Posts: 5
Joined: 2018-01-31T16:15:11-07:00
Authentication code: 1152

Re: mogrify -clone error help

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: mogrify -clone error help

Post by fmw42 »

Is libtif installed. That is does

magick -version

list tiff in the Delegates section

What was your exact command where it failed?
howtaebatch
Posts: 5
Joined: 2018-01-31T16:15:11-07:00
Authentication code: 1152

Re: mogrify -clone error help

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: mogrify -clone error help

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: mogrify -clone error help

Post 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.
snibgo's IM pages: im.snibgo.com
howtaebatch
Posts: 5
Joined: 2018-01-31T16:15:11-07:00
Authentication code: 1152

Re: mogrify -clone error help

Post by howtaebatch »

Got the command working; Batch file is working too. Thanks for the help guys! Appreciated.
Post Reply