Bug 111126 - identify command adds extra newline to formatted output
identify command adds extra newline to formatted output
Product: Fedora
Classification: Fedora
Component: ImageMagick (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Matthias Clasen
Mike McLean
Depends On:
  Show dependency treegraph
Reported: 2003-11-27 13:44 EST by Rick Johnson
Modified: 2007-11-30 17:10 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-09-30 19:29:30 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Rick Johnson 2003-11-27 13:44:53 EST
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):

How reproducible:

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"
"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 15:33:24 EST
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 16:20:19 EST
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 16:25:49 EST
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)
Comment 4 Rick Johnson 2003-11-27 17:19:52 EST
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

Comment 5 Boris Folgmann 2005-08-12 09:19:55 EDT
Fixed at least in current ImageMagick-
I suggest to close this.

Note You need to log in before you can comment on or make changes to this bug.