Page 1 of 1

Batch reset horizontal size without major increase in filesize

Posted: 2020-02-03T20:30:10-07:00
by Iftikhar Zaman
ALERT:I am new to graphics, new to IM!
I HAVE spent two weeks trying to solve this simple problem.
I have a batch of pictures of passport pages from my phone camera. They are around 300k each, jpg.
Before making a pdf of them I want to set them to the same horizontal size so that the pdf scrolls smoothly when used.
"identify *.jpg" shows horizontal size around 2000 so I use

mogrify -resize 2000 *.jpg

But filesize increases about three times?! I try

convert *.jpg -gravity center -extent 2000

but that also increases filesize many times. So: is there are way to batch reset width on jpegs before creating a pdf out of them without major increase in filesize?

Here is a link to ten of the files I am working with.

https://www.dropbox.com/sh/hl029ro0thfz ... 0xdYa?dl=0

[Using Raspberry Pi running Debian 10 Buster]

Re: Batch reset horizontal size without major increase in filesize

Posted: 2020-02-03T21:32:06-07:00
by fmw42
Add -quality before saving to JPG in mogrify or convert.

Or with convert, use -define jpeg:extent=size in kbytes.

See https://imagemagick.org/Usage/formats/#jpg_write

Your convert command is not correct. It needs an output name specified. So with convert, you will have to loop over each input and write one corresponding output. If you use wildcards in the input to convert and specify one single output name, then it will make multiple images with number appended such as file-0, file-1, etc.

Re: Batch reset horizontal size without major increase in filesize

Posted: 2020-02-03T21:38:15-07:00
by snibgo
I suggest "-quality 50%" to get a similar size with hardly any difference to the image.

Re: Batch reset horizontal size without major increase in filesize

Posted: 2020-02-04T04:34:08-07:00
by Iftikhar Zaman
Excellent! -quality 50% works great. I guess I was expecting the default conversion to preserve filesize: but my expectations are based on ignorance and hence cannot be relied upon! Thanks a lot.
(fmw42: No need for output filename as mogrify modifies the files in place)

Re: Batch reset horizontal size without major increase in filesize

Posted: 2020-02-04T10:39:38-07:00
by fmw42
(fmw42: No need for output filename as mogrify modifies the files in place)
I was referring to convert not mogrify. Convert needs an output file name.

Imagemagick will use the quality in the input if it was specified in the file; otherwise it uses 92. So 50 is much lower quality than the default 92. I guess your JPG files did not record the quality value.