Page 1 of 1

I can't make this script to run in

Posted: 2018-08-12T10:14:10-07:00
by pelornero
I have Windows 10 and ImageMagick-7.0.8

I want to apply this script which I found:

Code: Select all

magick 1.jpg -colorspace gray \( +clone -blur 0x1 \) +swap -compose divide -composite -linear-stretch 5%x0% a1.jpg
I receive the following error:

Code: Select all

magick: unable to open image '\(': No such file or directory @ error/blob.c/OpenBlob/3487.
magick: no decode delegate for this image format `' @ error/constitute.c/ReadImage/554.
Can you tell to what do I need to do in order to make this script run? :)

Re: I can't make this script to run in

Posted: 2018-08-12T10:31:23-07:00
by fmw42
Windows syntax is different from the Unix syntax command you were using. See https://www.imagemagick.org/Usage/windows/

Try removing the \s

Code: Select all

magick 1.jpg -colorspace gray ( +clone -blur 0x1 ) +swap -compose divide -composite -linear-stretch 5%x0% a1.jpg
If in a .bat script, then double the % to %%.

Re: I can't make this script to run in

Posted: 2018-08-12T10:31:38-07:00
by snibgo
In bash, parentheses () are special character so have to be escaped, and the bash escape character is backslash, so \( and \). Windows uses a different escape character, the caret ^ , and parentheses don't normally need to be escaped.

In Windows BAT, percent % is a special character, and need to be doubled %%.

See http://www.imagemagick.org/Usage/windows/

Re: I can't make this script to run in

Posted: 2018-08-12T12:48:03-07:00
by pelornero
It's working. Love you both!

Another question!!! :D

I have a folder of JPGs to witch I would like to apply the script. I found a topic regarding this problem where both of you answered ( viewtopic.php?t=29390 ).

I have the source folder in "C:\1". I want to put the result in "C:\2"

Code: Select all

 
 cd c:\1
 
 magick mogrify -path "C:\2" -format jpg ( +clone -blur 0x1 ) +swap -compose divide -composite -linear-stretch 5%x0% * 
I receive:

Code: Select all

 mogrify: unrecognized option `+clone' @ error/mogrify.c/MogrifyImageCommand/4533.

Re: I can't make this script to run in

Posted: 2018-08-12T13:28:48-07:00
by fmw42
Mogrify does not allow clones or parenthesis processing. You will have to write a bat script to loop over your input folder using magick command only and writing the output to the other folder. Sorry I do not use Windows. So perhaps one of the Windows users can help further.

Re: I can't make this script to run in

Posted: 2018-08-12T14:16:00-07:00
by snibgo
As Fred says. I suggest you write your command using "magick" without "mogrify". When you have tested it, put it inside a "for" loop, eg "for %F in (*.jpg) do ....

Type "help for" for help.

Re: I can't make this script to run in

Posted: 2018-08-12T15:13:46-07:00
by pelornero
It worked! Love u! :D

Code: Select all

cd c:\1
FOR %a in (*.jpg) DO magick %a ( +clone -blur 0x1 ) +swap -compose divide -composite -linear-stretch 5%x0% -rotate 0.5 small_%a
(c:\1 is the folder in which I have the images)


Another 2 questions! :D
1. Can I create a PDF file from the all pages I've just created in the code above using magick image code?

2. Can I apply this type of code (the code from the 1st post) to a multiple page PDF file? I'm sick of spliting the PDF in multiple JPEG, run the code, combine them back in PDF>

Re: I can't make this script to run in

Posted: 2018-08-12T15:42:13-07:00
by snibgo
pelornero wrote:1. Can I create a PDF file from the all pages I've just created in the code above using magick image code?
If they all fit into memory at the same time:

Code: Select all

magick *.jpg out.pdf
pelornero wrote:2. Can I apply this type of code (the code from the 1st post) to a multiple page PDF file? I'm sick of spliting the PDF in multiple JPEG, run the code, combine them back in PDF>
IM is a raster processor. When it reads a PDF, it rasterizes each page to a raster (pixel) image. When it writes a PDF, every page will be a single raster image. So what you want is probably a bad idea. But IM can do it

Any command with "+clone" almost certainly assumes it is working on a single image, not multiple images. You can re-write the command to work on multiple images but PDF pages tend to be large, too large to fit an entire rasterized document in memory. So it is usually better to split the PDF into pages, process each page, then combine them.

Re: I can't make this script to run in

Posted: 2018-08-13T20:33:13-07:00
by pelornero
Thank you. The command for combining pdf is a gift from gods.

And another question! :D
And a command to split a PDF in multiple images? I've tried

Code: Select all

magick -density 600 PV.pdf pv-%02d.jpg

And I receive

Code: Select all

magick: FailedToExecuteCommand `"gswin32c.exe" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r300x300"  "-sOutputFile=C://Temp/magick-2464Ivabi35us8wj%d" "-fC:Temp/magick-2464T55zT9-Z2JWy" "-fC:Temp/magick-24647koOf7a2DZuj"' (The system cannot find the file specified.
) @ error/delegate.c/ExternalDelegateCommand/459.
magick: PDFDelegateFailed `The system cannot find the file specified.
' @ error/pdf.c/ReadPDFImage/796.

Re: I can't make this script to run in

Posted: 2018-08-13T22:28:37-07:00
by fmw42
Do you have Ghostscript installed as a delegate to Imagemagick?

Does

Code: Select all

magick -version
or

Code: Select all

magick -list configure
list gs or gslib?