Page 1 of 1

puzzling error message

Posted: 2012-02-15T15:14:57-07:00
by fmw42
I am having trouble running a unix subshell command to process some IM commands (to make an animation) in IM 6.7.5.6 Q16 Mac OSX Snow Leopard.

The following mostly fails as follows, though infrequently in has worked from time to time. (see viewtopic.php?f=1&t=20317#p80821 and viewtopic.php?f=1&t=20317#p80831)


ww=`convert rose: -format "%w" info:`
hh=`convert rose: -format "%h" info:`
( for ((i=0; i<29; i++)); do
ii=`convert xc: -format "%[fx:-$ww*(1-$i/29)]" info:`
jj=`convert xc: -format "%[fx:-$hh*(1-$i/29)]" info:`
echo "$ii,$jj"
convert -delay 10 rose: -virtual-pixel tile -distort SRT "0,0 1, 0, $ii,$jj" miff:-
done ) | convert - -loop 0 rose_anim4.gif


convert: no decode delegate for this image format `/var/folders/Yy/YyU-87D4F+OjlYS1BLMfS++++TM/-Tmp-/magick-4I1ZkqaD' @ error/constitute.c/ReadImage/532.
convert: missing an image filename `rose_anim4.gif' @ error/convert.c/ConvertImageCommand/3016.



Can someone tell me what this means and how to avoid it? I am not sure if /var/folders is a standard directory? Is it safe to remove subdirectories within /var/folders, such as Yy and its contents? When I cd to the offending directory the file is gone, but there is another directory, TemporaryItems, which is empty.

Thanks.

Fred

Re: puzzling error message

Posted: 2012-02-15T17:15:10-07:00
by magick
We cannot reproduce the problem.

Try resetting the temporary path. Use export TMPDIR=/tmp for example. Does the script still fail?

Next try another format instead of MIFF. Try tiff:-, for example, or pam:-. Does the script still fail?

Re: puzzling error message

Posted: 2012-02-15T17:51:00-07:00
by fmw42
magick wrote:We cannot reproduce the problem.

Try resetting the temporary path. Use export TMPDIR=/tmp for example. Does the script still fail?

Next try another format instead of MIFF. Try tiff:-, for example, or pam:-. Does the script still fail?

Neither help! After exporting TMPDIR=/tmp

printenv
...
TMPDIR=/tmp
...

But now

ww=`convert rose: -format "%w" info:`
hh=`convert rose: -format "%h" info:`
( for ((i=0; i<29; i++)); do
ii=`convert xc: -format "%[fx:-$ww*(1-$i/29)]" info:`
jj=`convert xc: -format "%[fx:-$hh*(1-$i/29)]" info:`
echo "$ii,$jj"
convert -delay 10 rose: -virtual-pixel tile -distort SRT "0,0 1, 0, $ii,$jj" tiff:-
done ) | convert - -loop 0 rose_anim4.gif

convert: no decode delegate for this image format `/tmp/magick-fjLJbJ1A' @ error/constitute.c/ReadImage/532.
convert: missing an image filename `rose_anim4.gif' @ error/convert.c/ConvertImageCommand/3016.

And the file is missing from /tmp

cd /tmp
c-98-234-217-52:tmp fred$ ls -al
total 0
drwxrwxrwt 8 root wheel 272 Feb 15 17:12 .
drwxr-xr-x@ 6 root wheel 204 Apr 27 2010 ..
srwxr-xr-x 1 fred wheel 0 Feb 15 17:12 icssuis502
drwx------ 3 fred wheel 102 Feb 15 17:11 launch-7tbtUD
drwx------ 3 fred wheel 102 Feb 15 17:11 launch-AD7qiD
drwx------ 3 fred wheel 102 Feb 15 17:11 launch-bUZ1iH
drwx------ 3 _cvmsroot wheel 102 Feb 15 17:11 launchd-73.Bc5RSP
drwx------ 3 fred wheel 102 Feb 15 17:11 launchd-93.Y0mgpg


So bottom line is that I still get the error message, but now for the "magick" file in /tmp. It is like it does not get created or gets deleted too quickly.

Fred

P.S. Have you tried on your Mac (Lion? or Snow Leopard?)

Re: puzzling error message

Posted: 2012-02-15T19:14:35-07:00
by magick
We ran your script hundreds of times under Mac OS X Lion with ImageMagick 6.7.5-6 and each time ran without complaint. We're clueless why its failing for you.

Re: puzzling error message

Posted: 2012-02-15T20:19:40-07:00
by fmw42
It is very strange.

This works fine:

( for ((i=0; i<1; i++)); do
echo "i=$i"
convert -size 1x10 gradient: pam:-
done ) | cat -


But this fails:

( for ((i=0; i<1; i++)); do
echo "i=$i"
convert -size 1x10 gradient: pam:-
done ) | convert - tmp.gif

convert: no decode delegate for this image format `/tmp/magick-9kiSrMqQ' @ error/constitute.c/ReadImage/532.
convert: missing an image filename `tmp.gif' @ error/convert.c/ConvertImageCommand/3016.


Seems to have something to do with convert reading from standard in?

Might there be some permission problem?

Can you think of some other test that might help determine the issue?

Anyway for me to debug that might help find the problem as you cannot reproduce it?

Re: puzzling error message

Posted: 2012-02-15T20:51:17-07:00
by fmw42
Further illuminating Information:

This fails:

( for ((i=0; i<1; i++)); do
echo "i=$i"
convert -size 1x1 xc:white gif:-
done ) | convert - tmp.gif


But removing or commenting out the echo seems to work fine:

( for ((i=0; i<1; i++)); do
convert -size 1x1 xc:white gif:-
done ) | convert - tmp.gif


Am I misunderstand how subshells handle echo?

If not, can you retest my original script at the my first post above. I had tested it with the echo in it, but had removed it when I pasted it into my message as I thought it was just clutter. I have now restored the echo in my first post.

Re: puzzling error message

Posted: 2012-02-15T22:21:24-07:00
by anthony
fmw42 wrote:Am I misunderstand how subshells handle echo?
Yeap

You are having your final convert read from the standard output of the loop a stream of MIFF images.

EG: in this loop...

Code: Select all

for ((i=0; i<1; i++)); do
   convert -size 1x1 xc:white miff:-
done | convert - tmp.gif
the second convert is reading...
MIFF_image MIFF_image MIFF_image ...
and so on. MIFF images can be simply concatenated together to make a multiple image, image.

You can use MIFF, PBM, PGM, PPM, PAM, TXT image formats, for a concatenated image list.

You can not use GIF, PNG or JPEG as these image file formats do not 'concatenate' into a multi-image list,
but are full defined formats. GIF can have multiple images but does not 'concatenate'

See... http://www.imagemagick.org/Usage/files/#miff

When you add the echo.. The second convert is reading a character stream consisting of....
MIFF_image i=0 MIFF_image i=1 MIFF_image i=2 ...
So it reads one image, then sees the string "i=0" does not recognise it as an image and barfs...
no decode delegate for this image format

If you want to echo some information you must NOT echo it the for-loops standard output data stream of images. The best solution is to echo to standard error (file descriptor '2').

As such this will work...

Code: Select all

for ((i=0; i<10; i++)); do
  echo >&2 "i=$i"
  convert -size 1x1 xc: miff:-
done | convert - tmp.gif
You can also use echo >/dev/tty "i=$i" as well.

ASIDE; this is why many 'debug' outputs of IM will write to STDERR instead of STDOUT, that way images being piped out does not include that non-image debug info. EG output from things like..
-define distort:verbose=1
-define filter:verbose=1
-define showkernel=1
and in 'most' cases
-verbose

Some text output output in IM goes to standard output. -print -identify But provides no method of changing it a file or stream...
See IM Exmaples, Basics, Identify Alternatives - Text Output Options
http://www.imagemagick.org/Usage/basics/#identify_alt

The coders like info: and txt: also default to STDOUT, can be re-directed files of other file streams. For example info:fd:2 outputs to STDERR.

For example, this works fine to report image info while not effecting the output muilt-image stream.

Code: Select all

for ((i=0; i<10; i++)); do
  convert -size 1x1 xc:  -write info:fd:2  miff:-
done | convert - tmp.gif

As part of IMv7 CLI updates, I plan of better control of to which file descriptor various debugging output text is to be directed.

Suggestions welcome.

Re: puzzling error message

Posted: 2012-02-16T11:09:53-07:00
by fmw42
Thank you Anthony. I understood the limitations on using multi-frame formats and you told me about doing this kind of looping in a subshell, which I have used in other scripts successfully. What I was not understanding was the echo issue and the need to send it to stderr.
Anthony wrote:for ((i=0; i<10; i++)); do
echo >&2 "i=$i"
convert -size 1x1 xc: miff:-
done | convert - tmp.gif
Now this makes sense and solves my problem and misunderstanding.

Sorry this got a bit more unix than IM. But I greatly appreciate your help and explanation

Fred

P.S. Magick, thanks for all your help as well. Sorry I lead you down a bogus path leaving the echo out of my first post. However, retesting that code rather than my non-posted test with the echo is what lead me to find that the echo was the issue.

Re: puzzling error message

Posted: 2012-02-16T17:50:28-07:00
by anthony
It is easy to do..

I have done it so many times myself in scripting, and the error message is misleading, even though it is accurate!