Bug 111126

Summary: identify command adds extra newline to formatted output
Product: [Fedora] Fedora Reporter: Rick Johnson <htmlspinnr>
Component: ImageMagickAssignee: Matthias Clasen <mclasen>
Status: CLOSED RAWHIDE QA Contact: Mike McLean <mikem>
Severity: medium Docs Contact:
Priority: medium    
Version: 1   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-09-30 23:29:30 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Rick Johnson 2003-11-27 18:44:53 UTC
From Bugzilla Helper:

Description of problem:
The format flag on the identify command within ImageMagick appears to 
have an erroneous newline added to the end. According to the docs, 
there are flags for adding newline if using the format flag. However, 
this version appears to be adding at least one newline. 

Version-Release number of selected component (if applicable):
ImageMagick-5.5.6-5

How reproducible:
Always

Steps to Reproduce:
1. /usr/bin/identify -ping -format "%w %h %m %b" imagename
2. Note newline on output

Actual Results:  

Command returns: "1600 1200 JPEG 441.4k\n"
or
"1600 1200 JPEG 441.4k
"

Expected Results: 
Command to return: "1600 1200 JPEG 441.4k"

Additional info:

The format flag has a character for newline and/or linefeed, which 
will add an additional newline or linefeed. This bug is causing 
problems with a PHP script which attempts to read the output sans 
newline and put it into an array. Previous behavior excluded the 
newline. Other programs which utilize imagemagick in this manner 
would have similar problems.

Comment 1 Rick Johnson 2003-11-27 20:33:24 UTC
File magick/command.c
Line 3388: 

(void) ConcatenateString(&(*metadata),"\n");

Other lines like it exist within the source. Either this line, or the
function ConcatenateString need to make concatenating a newline
conditional on the format flag. If format is used and no "\n" is
contained, no \n should be concatenated.

Commenting out this line and rebuilding seems to solve my problem for
script output, but probably breaks other functionality. 

Comment 2 Rick Johnson 2003-11-27 21:20:19 UTC
It would appear that previous versions used something similar, so it
would appear that an additional newline is being introduced within a
different function. 

Comment 3 Rick Johnson 2003-11-27 21:25:49 UTC
utilities/identify.c:
Line 194:
      (void) fputc('\n',stdout);

The presence of this as well as the initial line appears to be
creating two newlines. IMHO, one or the other should go. the line
within identify.c seems to have been present in previous (<=5.4.x)
versions. 


Comment 4 Rick Johnson 2003-11-27 22:19:52 UTC
Owner has patch 5.5.8 upstream beta, will be available via FTP within
a couple of days.

Reference http://studio.imagemagick.org/magick/viewtopic.php?p=2054#2054

-Rick

Comment 5 Boris Folgmann 2005-08-12 13:19:55 UTC
Fixed at least in current ImageMagick-6.2.2.0-2.fc3.
I suggest to close this.