Page 1 of 1

Convert multi image PDF in single files with image size in title

Posted: 2018-02-01T06:47:37-07:00
by LittleKI
Hi,

i use this command line to convert multi image pdfs into single files:

Code: Select all

convert -density 300x300 -units pixelsperinch input -background white -alpha background -alpha off -antialias -compress zip +adjoin output.tiff
then i tried to add some information into the output filename as i could read here: viewtopic.php?t=17149. i tried this command line:

Code: Select all

convert -density 300x300 -units pixelsperinch input -background white -alpha background -alpha offantialias -compress zip -set filename:mysize '%wx%h' +adjoin output_%[filename:mysize].tif
convert only writes the first side as a image. the output filename is correct: new_2250x4000.tif

what is wrong with the second command? why only the first image is written to a image?

Re: Convert multi image PDF in single files with image size in title

Posted: 2018-02-01T10:27:34-07:00
by snibgo
I suspect they are all being written, but they have the same size, so they have the same name. Your filename overrides the default numbering mechanism.

Re: Convert multi image PDF in single files with image size in title

Posted: 2018-02-01T11:26:04-07:00
by LittleKI
yes, its right.

but normally when i use normal output convert creates numbers after the filename, like output1.tif output2.tif. this doesn't work when i use the output with image size in the file name. when i try this

Code: Select all

convert -density 300x300 -units pixelsperinch input.pdf -background white -alpha background -alpha off -antialias -compress zip -set filename:mysize '%wx%h' +adjoin new_%[filename:mysize]_%02d.tif
i have 1 output file and the name is 'new_2250x4000_%02d.tif.tif'. when i try this

Code: Select all

convert -density 300x300 -units pixelsperinch input.pdf -background white -alpha background -alpha off -antialias -compress zip -set filename:mysize '%wx%h' +adjoin new_%02d_%[filename:mysize].tif
i have one image for every side and the output name are new_00_%[2250x4000.tif and new_01_%[2250x4000.tif.

what is the right way to output the images with the image size in the name AND with correct numbering?

Re: Convert multi image PDF in single files with image size in title

Posted: 2018-02-01T11:45:02-07:00
by snibgo
I would use %s in the "-set filename", so you can have it wherever you want, eg:

Code: Select all

-set filename:mysize '%wx%h_%s'
-set filename:mysize '%s_%wx%h'

Re: Convert multi image PDF in single files with image size in title

Posted: 2018-02-01T11:55:21-07:00
by fmw42
Please always provide your IM version and platform/OS when asking questions.

I do not believe you can use more than one % in your output file name. But you can get the scene number from %s. So this works.

Code: Select all

convert -density 150 test.pdf -set filename:mysize '%s_%wx%h' -compress zip +adjoin new_%[filename:mysize].tif
Produces:

Code: Select all

new_0_533x533.tif
new_1_552x694.tif
new_2_833x623.tif
I think it would need a new -define to be created to tell IM that scene numbers should have leading zeros or a new string format.

Also I note that when I add -scene 1 to the command line, it did not shift the numbers to start with 1.

Re: Convert multi image PDF in single files with image size in title

Posted: 2018-02-02T08:56:02-07:00
by LittleKI
i use version 6.8.9.9 on ubuntu 16.04.
I think it would need a new -define to be created to tell IM that scene numbers should have leading zeros or a new string format.
what do you mean? i read the command line options but didn't understand ow i can do this with -define.

Re: Convert multi image PDF in single files with image size in title

Posted: 2018-02-02T10:10:51-07:00
by fmw42
The define does not exist, yet. I was suggesting that a new one would be needed to do what you want, i.e. an enhancement to imagemagick.

Re: Convert multi image PDF in single files with image size in title

Posted: 2018-02-02T12:05:04-07:00
by LittleKI
but how can i create a new one? i dont understand whats written in "command line option".

Re: Convert multi image PDF in single files with image size in title

Posted: 2018-02-02T12:14:23-07:00
by fmw42
You cannot, unless you can code for ImageMagick. You need to request and enhancement for such. See my the bottom of my bug report at viewtopic.php?f=3&t=33455. You can make a formal request for such an enhancement on the Developers forum.