Hiccup during Image Upload/Processing

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
conditionedBeard

Hiccup during Image Upload/Processing

Post by conditionedBeard »

Hello everyone,

Have an error message, which sometimes shows, sometimes it doesn't.
Would like to get some feedback please. :)

I am running a resize command, which sometimes produces an error.
The command is:

Code: Select all

convert ../testuser/live00001.jpg -resize 225x169 ../thumbs/tinylive.jpg
The two eMails that sometimes arrive with the error message are:
convert: Empty input file ` ../testuser/live00001.jpg' @ error/jpeg.c/EmitMessage/233.
convert: missing an image filename `../thumbs/tinylive.jpg' @ error/convert.c/ConvertImageCommand/2919.

AND

convert: Premature end of JPEG file `../testuser/live00001.jpg' @ warning/jpeg.c/EmitMessage/228.
convert: Corrupt JPEG data: premature end of data segment `../testuser/live00001.jpg' @ warning/jpeg.c/EmitMessage/228.
I believe these are occurring because the images are uploaded by "wireless modems".
These wireless modems have "scetchy" signals... thus the upload sometimes 'hangs' and stays mid-way.

Is there a way to set a parameter, to check if the images is being rewritten, or if it is 0kB, not to process?

Thoughts?
Thank you very much for the help!
Much appreciated :)

Let me know if you need more information!

-- HP
.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Hiccup during Image Upload/Processing

Post by fmw42 »

see unix commands; search google for file tests, e.g

http://tldp.org/LDP/abs/html/fto.html
http://linuxreviews.org/beginner/bash_G ... Reference/

use such tests in an conditional with your convert so that if it fails, it does not do the convert

# test if image an ordinary, readable and non-zero size
if [ -f $infile -a -r $infile -a -s $infile ]; then
convert ...
else
echo "--- FILE $infile DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO SIZE ---"
exit 1
fi


OR

if convert -quiet -regard-warnings "$infile" ...
then
: ' do nothing '
else
echo "--- FILE $infile DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAG ZERO SIZE ---"
fi
conditionedBeard

Re: Hiccup during Image Upload/Processing

Post by conditionedBeard »

Hello fmw42,
It took me a while, yet I did the fix with your examples, and everything is working flawlessly.

Thank you very much for your help.
I didn't thank you when you posted.

Have a good one! :)

fmw42 wrote:see unix commands; search google for file tests, e.g

http://tldp.org/LDP/abs/html/fto.html
http://linuxreviews.org/beginner/bash_G ... Reference/

use such tests in an conditional with your convert so that if it fails, it does not do the convert

# test if image an ordinary, readable and non-zero size
if [ -f $infile -a -r $infile -a -s $infile ]; then
convert ...
else
echo "--- FILE $infile DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO SIZE ---"
exit 1
fi


OR

if convert -quiet -regard-warnings "$infile" ...
then
: ' do nothing '
else
echo "--- FILE $infile DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAG ZERO SIZE ---"
fi
Post Reply