Resizing jpegs, limiting file size

Hello All, I am wanting to cut the file size of photos from my phone. I have tried opening in GIMP, but takes a bit of mousing and clicking around, and even saving/exporting several times to get the size down. I think the imagemagik suite should be able to do, but my reading of the man pages does not make it apparent to me. They talk of resizing, but it looks like the linear extent, rather than loosing some detail of the same extent of image. I would appreciate any contributions. regards, Mark Trickett

Hi Mark, If you have ImageMagick installed on your system you can use the utility convert to manage this for you. Usage: convert [options ...] file [ [options ...] file ...] [options ...] file If you want to do an entire folder/directory in one go let me know off list as we use a script to automate it for our use. best wishes Tony White On 14/05/2017 17:55, Mark Trickett via luv-main wrote:
Hello All,
I am wanting to cut the file size of photos from my phone. I have tried opening in GIMP, but takes a bit of mousing and clicking around, and even saving/exporting several times to get the size down. I think the imagemagik suite should be able to do, but my reading of the man pages does not make it apparent to me. They talk of resizing, but it looks like the linear extent, rather than loosing some detail of the same extent of image. I would appreciate any contributions.
regards,
Mark Trickett _______________________________________________ luv-main mailing list luv-main@luv.asn.au https://lists.luv.asn.au/cgi-bin/mailman/listinfo/luv-main

Hello Tony and Kathy, On 5/14/17, Tony White via luv-main <luv-main@luv.asn.au> wrote:
Hi Mark, If you have ImageMagick installed on your system you can use the utility convert to manage this for you.
Usage: convert [options ...] file [ [options ...] file ...] [options ...] file
It is filling in the options that has me scratching and not getting there at the moment. To Kathy, I did look at the link, and it reflects what I have read. The GIMP is not small, it is not quick to load, and it can take several saves to get the file size small enough, I have even had the file size grow. To Andrew Greig, these are coming from an old Nokia phone in jpeg format to start with.
If you want to do an entire folder/directory in one go let me know off list as we use a script to automate it for our use.
I am interested, but still need to know the options.
best wishes Tony White
Regards, Mark Trickett

Hi Mark, This converts all images in a folder to 320 px wide and height autoscaled proportionally. #!/bin/sh # run this is script in the image folder # change the value 320 to whatever width you want response = 320 for f in *; do # prefix the results with sm_ or change to what you want convert $f -resize $response +profile "*" sm_$f done best wishes Tony White On 14/05/2017 18:42, Mark Trickett via luv-main wrote:
Hello Tony and Kathy,
On 5/14/17, Tony White via luv-main <luv-main@luv.asn.au> wrote:
Hi Mark, If you have ImageMagick installed on your system you can use the utility convert to manage this for you.
Usage: convert [options ...] file [ [options ...] file ...] [options ...] file It is filling in the options that has me scratching and not getting there at the moment. To Kathy, I did look at the link, and it reflects what I have read. The GIMP is not small, it is not quick to load, and it can take several saves to get the file size small enough, I have even had the file size grow. To Andrew Greig, these are coming from an old Nokia phone in jpeg format to start with.
If you want to do an entire folder/directory in one go let me know off list as we use a script to automate it for our use. I am interested, but still need to know the options.
best wishes Tony White Regards,
Mark Trickett _______________________________________________ luv-main mailing list luv-main@luv.asn.au https://lists.luv.asn.au/cgi-bin/mailman/listinfo/luv-main

On Sun, May 14, 2017 at 07:02:41PM +1000, Tony White wrote:
#!/bin/sh # run this is script in the image folder # change the value 320 to whatever width you want response = 320 for f in *; do # prefix the results with sm_ or change to what you want convert $f -resize $response +profile "*" sm_$f done
You really should quote your variables. If any of the filenames have spaces (or other problematic characters like *, ?, [, (, and other characters with special meaning to the shell) in them, this script will break. Those are all valid characters in a filename on all linux filesystems. There are only two characters which are not valid in a filename, a forward-slash and a NUL byte. Anything else is permitted. To avoid any problems cause by such annoying characters, you should surround variables names with double-quotes when you use them, for the same reason you quoted the "*". e.g. convert "$f" -resize "$response" +profile "*" "sm_$f" There are other reasons to quote variables, especially when you can not have complete knowledge or control over the value of a variable. As a general rule, **ALWAYS** double-quote variables when you use them. It can pretty nearly never hurt to double-quote a variable, but there are plenty of situations using an unquoted variable can cause severe damage. (NOTE: there are some very specific rare situations where you don't want to and shouldn't quote variables, but if you´re capable of writing the kind of shell code that requires that, you'll know when not to quote. Otherwise, just quote variables all the time: 999999 times out of 1000000 (or more) it is exactly the right, safe, and correct thing to do. Or, to put it another way, unless you know exactly WHY you don't want to quote a specific variable, then quote it) BTW, this script has clearly not been tested - typed in from memory? There should be no space between the variable name, the equals sign, or the value being assigned. ´response=320' would assign the value 320 to the variable $response. 'response = 320' does not, it is an attempt to run a command called 'response' with two command line arguments '=' and '320'. Also BTW, use double-quotes when you need to interpolate variables or sub-shell results etc into a string, and it's best to use single-quotes otherwise, like so: convert "$f" -resize "$response" +profile '*' "sm_$f" That's the key difference between double and single-quotes - single-quotes are for static, fixed, literal strings. Double-quotes are for for variables and other dynamically generated output. Finally, when passing filename arguments to programs that understand the GNU convention of '--' to indicate the end of program options, it's also always a good idea to use it to prevent filenames beginning with a '-' from being interpreted as options. e.g. if a directory contains a file called '-rf' in it, there is a huge difference between running 'rm *' and 'rm -- *' craig -- craig sanders <cas@taz.net.au>

On 14.05.2017 17:55, Mark Trickett via luv-main wrote:
Hello All,
I am wanting to cut the file size of photos from my phone. I have tried opening in GIMP, but takes a bit of mousing and clicking around, and even saving/exporting several times to get the size down. I think the imagemagik suite should be able to do, but my reading of the man pages does not make it apparent to me. They talk of resizing, but it looks like the linear extent, rather than loosing some detail of the same extent of image. I would appreciate any contributions.
regards,
Mark Trickett _______________________________________________ luv-main mailing list luv-main@luv.asn.au https://lists.luv.asn.au/cgi-bin/mailman/listinfo/luv-mainT
To scale an image in gimp load the image go to menu item "image>Scale Image" type in size, press scale. Examine the result. To save use menu item "File>Export As..." Close file, a box will come to save or discard file, press discard. If only doing a small number of images (below say 20) I use this particularly if accurate size is important, say for desktop backgrounds.. On the command line when doing work on a lot of images consider the Netpbm tools, this is a large set of command line tools that will allow one to do almost ANYTHING with images on the command line, For scaling images "pnmscale" does the job..... Note: This is from an uptodate version of Netpbm, I believe the one in Debian is VERY old. pnmscale(1) General Commands Manual pnmscale(1) NAME pnmscale - scale a portable anymap SYNOPSIS pnmscale scale_factor [pnmfile] pnmscale -reduce reduction_factor [pnmfile] pnmscale [{-xsize=cols | -width=cols | -xscale=factor}] [{-ysize=rows | -height=rows | -yscale=factor}] [pnmfile] pnmscale -xysize cols rows [pnmfile] pnmscale -pixels n [pnmfile] Miscellaneous options: -verbose -nomix Minimum unique abbreviation of option is acceptable. You may use double hypens instead of single hyphen to denote options. You may use white space in place of the equals sign to separate an option name from its value. DESCRIPTION Reads a PBM, PGM, or PPM image as input, scales it by the specified factor or factors and produces a PGM or PPM image as output. If the input file is in color (PPM), the output will be too, otherwise it will be grayscale (PGM). This is true even if the input is a black and white bitmap (PBM), because the process of scaling can turn a combination of black and white pixels into a gray pixel. If you want PBM output, use pgmtopbm to convert pnmscale's output to PBM. Also consider pbmreduce. You can both enlarge (scale factor > 1) and reduce (scale factor < 1). When you specify an absolute size or scale factor for both dimensions, pnmscale scales each dimension independently without consideration of the aspect ratio. If you specify one dimension as a pixel size and don't specify the other dimension, pnm- scale scales the unspecified dimension to preserve the aspect ratio. If you specify one dimension as a scale factor and don't specify the other dimension, pnm- scale leaves the unspecified dimension unchanged from the input. If you specify the scale_factor parameter instead of dimension options, that is the scale factor for both dimensions. It is equivalent to -xscale=scale_factor -yscale=scale_factor . Specifying the -reduce reduction_factor option is equivalent to specifying the scale_fac- tor parameter, where scale_factor is the reciprocal of reduction_factor. -xysize specifies a bounding box. pnmscale scales the input image to the largest size that fits within the box, while preserving its aspect ratio. -pixels specifies a maximum total number of output pixels. pnmscale scales the image down to that number of pixels. If the input image is already no more than that many pixels, pnmscale just copies it as output; pnmscale does not scale up with -pixels. ............................ much text cut out..................

Also have a look at FIJI (FIJI Is Just ImageJ) as it's emminently scriptable, so I'm told... On 14 May 2017 at 20:29, Ray via luv-main <luv-main@luv.asn.au> wrote:
On 14.05.2017 17:55, Mark Trickett via luv-main wrote:
Hello All,
I am wanting to cut the file size of photos from my phone. I have tried opening in GIMP, but takes a bit of mousing and clicking around, and even saving/exporting several times to get the size down. I think the imagemagik suite should be able to do, but my reading of the man pages does not make it apparent to me. They talk of resizing, but it looks like the linear extent, rather than loosing some detail of the same extent of image. I would appreciate any contributions.
regards,
Mark Trickett _______________________________________________ luv-main mailing list luv-main@luv.asn.au https://lists.luv.asn.au/cgi-bin/mailman/listinfo/luv-mainT
To scale an image in gimp load the image go to menu item "image>Scale Image" type in size, press scale. Examine the result. To save use menu item "File>Export As..." Close file, a box will come to save or discard file, press discard.
If only doing a small number of images (below say 20) I use this particularly if accurate size is important, say for desktop backgrounds..
On the command line when doing work on a lot of images consider the Netpbm tools, this is a large set of command line tools that will allow one to do almost ANYTHING with images on the command line, For scaling images "pnmscale" does the job..... Note: This is from an uptodate version of Netpbm, I believe the one in Debian is VERY old.
pnmscale(1) General Commands Manual pnmscale(1)
NAME pnmscale - scale a portable anymap
SYNOPSIS pnmscale scale_factor [pnmfile] pnmscale -reduce reduction_factor [pnmfile] pnmscale [{-xsize=cols | -width=cols | -xscale=factor}] [{-ysize=rows | -height=rows | -yscale=factor}] [pnmfile] pnmscale -xysize cols rows [pnmfile] pnmscale -pixels n [pnmfile]
Miscellaneous options: -verbose -nomix
Minimum unique abbreviation of option is acceptable. You may use double hypens instead of single hyphen to denote options. You may use white space in place of the equals sign to separate an option name from its value.
DESCRIPTION Reads a PBM, PGM, or PPM image as input, scales it by the specified factor or factors and produces a PGM or PPM image as output. If the input file is in color (PPM), the output will be too, otherwise it will be grayscale (PGM). This is true even if the input is a black and white bitmap (PBM), because the process of scaling can turn a combination of black and white pixels into a gray pixel.
If you want PBM output, use pgmtopbm to convert pnmscale's output to PBM. Also consider pbmreduce.
You can both enlarge (scale factor > 1) and reduce (scale factor < 1).
When you specify an absolute size or scale factor for both dimensions, pnmscale scales each dimension independently without consideration of the aspect ratio.
If you specify one dimension as a pixel size and don't specify the other dimension, pnm- scale scales the unspecified dimension to preserve the aspect ratio.
If you specify one dimension as a scale factor and don't specify the other dimension, pnm- scale leaves the unspecified dimension unchanged from the input.
If you specify the scale_factor parameter instead of dimension options, that is the scale factor for both dimensions. It is equivalent to -xscale=scale_factor -yscale=scale_factor .
Specifying the -reduce reduction_factor option is equivalent to specifying the scale_fac- tor parameter, where scale_factor is the reciprocal of reduction_factor.
-xysize specifies a bounding box. pnmscale scales the input image to the largest size that fits within the box, while preserving its aspect ratio.
-pixels specifies a maximum total number of output pixels. pnmscale scales the image down to that number of pixels. If the input image is already no more than that many pixels, pnmscale just copies it as output; pnmscale does not scale up with -pixels.
............................ much text cut out..................
_______________________________________________ luv-main mailing list luv-main@luv.asn.au https://lists.luv.asn.au/cgi-bin/mailman/listinfo/luv-main
-- Dr Paul van den Bergen

Mark Trickett via luv-main wrote:
Hello All,
I am wanting to cut the file size of photos from my phone. I have tried opening in GIMP, but takes a bit of mousing and clicking around, and even saving/exporting several times to get the size down. I think the imagemagik suite should be able to do, but my reading of the man pages does not make it apparent to me. They talk of resizing, but it looks like the linear extent, rather than loosing some detail of the same extent of image. I would appreciate any contributions.
regards,
Mark Trickett _______________________________________________ luv-main mailing list luv-main@luv.asn.au https://lists.luv.asn.au/cgi-bin/mailman/listinfo/luv-main Mark: if you want a simple GUI interface; try XnViewMp http://download.xnview.com but I suspect most image viewers; allow simple 'on screen' image size reduction followed by 'save as'; usually with a batch option.Also Irfanview which may have a more intuitive GUI; is reported to'sortof' run under Wine !
regards Rohan McLeod

Hi Mark, Have you considered Digikam ( https://digikam.org) ? It has a Batch Queue Manager with which you can bulk resize as well as lots of photo editing facilities. I use it for almost all of my photography stuff now. Bob On 14/05/17 17:55, Mark Trickett via luv-main wrote:
Hello All,
I am wanting to cut the file size of photos from my phone. I have tried opening in GIMP, but takes a bit of mousing and clicking around, and even saving/exporting several times to get the size down. I think the imagemagik suite should be able to do, but my reading of the man pages does not make it apparent to me. They talk of resizing, but it looks like the linear extent, rather than loosing some detail of the same extent of image. I would appreciate any contributions.
regards,
Mark Trickett _______________________________________________ luv-main mailing list luv-main@luv.asn.au https://lists.luv.asn.au/cgi-bin/mailman/listinfo/luv-main

Hi Mark On Tue, May 16, 2017 at 1:34 PM, Bob via luv-main <luv-main@luv.asn.au> wrote:
Have you considered Digikam ( https://digikam.org) ? It has a Batch Queue Manager with which you can bulk resize as well as lots of photo editing facilities. I use it for almost all of my photography stuff now.
Bob
I second Digikam I use it both in Linux and Windows -- Mark "Pockets" Clohesy PH: +61 4 06417877 hiddensoul@twistedsouls.com GNU/Linux.. Linux Counter #457297 "In the 60's, people took acid to make the world weird. Now the world is weird and people take Prozac to make it normal.." "Well, strangely enough, ma'am, I don't have that information in my database. My programmers, for some insane reason, decided that 'dinosaur bowel movement frequency' tables wouldn't be required. Imbeciles!"
participants (9)
-
Bob
-
Craig Sanders
-
Karl Billeter
-
Mark Clohesy
-
Mark Trickett
-
Paul van den Bergen
-
Rohan McLeod
-
Tony White
-
zlinew9@virginbroadband.com.au