Convert hangs when pinging text file

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
saulspatz
Posts: 1
Joined: 2015-04-24T01:03:00-07:00
Authentication code: 6789

Convert hangs when pinging text file

Post by saulspatz »

convert ~/Desktop/formats.txt -ping -format %[fx:w]x[fx:h] :info
Killed: 9

This seems to get into an infinite loop. The file can be retrieved from https://dl.dropboxusercontent.com/u/247 ... ormats.txt

I am running ImageMagick 6.9.1-0 Q16 x86_64 2015-04-06 on OSX 10.10.3 (Yosemite)

There seems to be a problem with this particular file. I can ping other text files. My client has hundreds of thousands of images in a wide variety of formats that I need to convert to JPG. I'm in the process of testing what might go wrong. The relevant lines from my python script are

Code: Select all

size = subprocess.check_output(['convert', fd.oldPath, '-ping', '-format', '%[fx:w]x%[fx:h]', 'info:'], stderr=log)
subprocess.call(['convert', fd.oldPath,  '-size', size, 'tile:pattern:checkerboard',
                         '-brightness-contrast', '20,10', '+swap', '-compose',
                         'over', '-composite', '-quality', str(self.quality), fd.newPath],
                         stdout=log, stderr=log)  
When it hits this file, the call to subprocess.check_output() never returns, and I have to restart my Mac. I plan to filter out text files, of course, but I'm worried that this might happen with a corrupt image file. Can you suggest a defensive measure I might take?

I ran this again, using a python script attributed to Alex Martelli that I found at http://stackoverflow.com/questions/1191 ... th-timeout. (It's about the fourth answer down, or so.) This time it runs to completion, and gives the output '612x792612x792612x792612x792'. Perhaps it's splitting the document up into 4 pages? Watching the script in a debugger, it looks like convert has filled its output buffer, and is waiting for someone to read it, but that's just a guess; I don't really know what I'm talking about.

Since I was expecting output in the form "w x h" I don't know if this is user error or a bug.

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

Re: Convert hangs when pinging text file

Post by fmw42 »

convert ~/Desktop/formats.txt -ping -format %[fx:w]x[fx:h] :info
Bad syntax. The colon goes at the end of info: Also -ping should go before the input image

The following works fine for me on IM 6.9.1.2 Q16 Mac OSX

Code: Select all

convert -ping formats.txt -format "%wx%h" info:
612x792612x792612x792612x792612x792Fred-Weinhauss-Mac-mini:desktop fred$ 
Post Reply