Problems with Fred's downsize script
Posted: 2016-02-02T04:08:41-07:00
I'm trying to use http://www.fmwconcepts.com/imagemagick/ ... /index.php to reduce some JPEG-2000 images to a specified target size, per viewtopic.php?p=127981#p127981 Thank you for providing this useful utility!
It would be useful to know some examples of formats and environments that the script has been tested with. I'm testing on fedora 23 but the end user needs it on OSX.
1) bash complains about -gt expecting a unary operator at line 239 because at the line the fullsize variable fails to be defined. I don't understand the -ping mechanics, is this expected to work with JP2? If I knew where the file is created I could work around with something like
2) The same size comparison fails in some cases, for instance when the size ends up being expressed in floating point. Example with an echo for the two compared variables:
3) https://stackoverflow.com/a/18798240 suggests to use ksh but then there are compatibility issues:
4) The same attempt with ksh gave also
I'm not sure if it simply failed to defined the options correctly or if it's an issue with the file. It's a 24 bit JPEG image of 10 MPx.
It would be useful to know some examples of formats and environments that the script has been tested with. I'm testing on fedora 23 but the end user needs it on OSX.
1) bash complains about -gt expecting a unary operator at line 239 because at the line
Code: Select all
fullsize=`convert $tmpA1 ${ftype}:- | convert - -ping -format "%b" info: | tr -d "[:alpha:]"`
Code: Select all
if [ -z $fullsize ]; then
fullsize=$(du "$outfile" | cut -f1 )
fi
Code: Select all
$ ./downsize.sh -s 2500 -t 15 Scan0001.jp2 0001.jp2
0
2.5e+06
./downsize.sh: line 244: [: 2.5e+06: integer expression expected
Code: Select all
downsize.sh[91]: whence: downsize.sh: not found
dirname: operando mancante
Try 'dirname --help' for more information.
basename: operando mancante
Try 'basename --help' for more information.
Code: Select all
convert: unable to write pixel cache `/tmp/magick-21362ZcAQ8qAzXoHy': Spazio esaurito sul device @ error/cache.c/WritePixelCachePixels/5525.
convert: unable to extend cache `./downsize_1_21321.mpc': Spazio esaurito sul device @ error/cache.c/OpenPixelCache/3728.