Page 1 of 1

help detecting misleading argumetns ofr Convert

Posted: 2012-02-22T11:41:27-07:00
by brutuscat
Hi, I'm using Ruby's Paperclip gem and I have a very weird error coming from the "convert" command. It seems that paperclip goes nuts somewhere and it may be swallowing some argument when building up the full command line to execute.

So this is what paperclip "says" it is executing, which it works fine if I copy paste it in my console:

Code: Select all

convert /tmp/stream20120222-16799-h6517r.txt[0]' -resize "90x90^" -unsharp 0x.7 -gravity center -extent 90x90 '/tmp/stream20120222-16799-h6517r20120222-16799-1yalfzi.gif'
So the above WORKS :D

But somehow Paperclip is messing up something, and I'm thinking that one thing is what it "says" it is executing and another thing it's what it actually "runs". So when running inside Paperclip I'm getting this error from "convert":

Code: Select all

convert: invalid argument for option `90x90^': -resize.
What's puzzling me is that "convert" thinks that "90x90^" is the option and "-resize" is the argument of the option. So something is pretty wrong in how Paperclip is building the command. But I can't figure it what!

So what I'm asking here is if somebody could help me out to understand how Paperclip is messing around the arguments for such an error to show up. For example it would be great to know what argument needs to be missing so the error shown pops up ;)

Thanks!

Re: help detecting misleading argumetns ofr Convert

Posted: 2012-02-22T11:44:42-07:00
by fmw42
Sorry I know nothing about paperclip.

Just some sanity checks ---

What version of IM are you using? The ^ option was not added until IM IM 6.3.8-2. However it is strange that it works in your terminal but not in your paperclip. Perhaps ^ means something special in paperclip?

try escaping ^ and no quotes and see if that helps

-resize 90x90\^

Re: help detecting misleading argumetns ofr Convert

Posted: 2012-02-22T12:07:08-07:00
by brutuscat
Thank you very much for your reply :D

Yeah I tried escaping and removing quotes and seems to works always...

This is my ImageMagick version

Code: Select all

convert --version
Version: ImageMagick 6.7.5-6 2012-02-22 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP 
and the config

Code: Select all

convert -list configure

Path: /home/entretenerse/lib/ImageMagick-6.7.5/config/configure.xml

Name          Value
-------------------------------------------------------------------------------
CC            gcc -std=gnu99 -std=gnu99
CFLAGS        -fopenmp -g -O2 -Wall -pthread
CODER_PATH    /home/entretenerse/lib/ImageMagick-6.7.5/modules-Q16/coders
CONFIGURE     ./configure  '--prefix=/home/entretenerse' '--without-perl' '--with-lzma=yes' '--with-lcms2=yes'
CONFIGURE_PATH /home/entretenerse/etc/ImageMagick/
COPYRIGHT     Copyright (C) 1999-2012 ImageMagick Studio LLC
CPPFLAGS      -I/home/entretenerse/include/ImageMagick
CXX           g++
CXXFLAGS      -g -O2 -pthread
DEFS          -DHAVE_CONFIG_H
DELEGATES     bzlib fontconfig freetype jpeg jng lcms mpeg png tiff x11 xml zlib
DISTCHECK_CONFIG_FLAGS --disable-deprecated --with-quantum-depth=16 --with-umem=no --with-autotrace=no --with-gslib=no --with-fontpath= --with-wmf=no --with-perl=no
DOCUMENTATION_PATH /home/entretenerse/share/doc/ImageMagick/
EXEC-PREFIX   /home/entretenerse
EXECUTABLE_PATH /home/entretenerse/bin
FEATURES      OpenMP 
FILTER_PATH   /home/entretenerse/lib/ImageMagick-6.7.5/modules-Q16/filters
HOST          i686-pc-linux-gnu
INCLUDE_PATH  /home/entretenerse/include/ImageMagick
LDFLAGS       -L/home/entretenerse/lib -L/usr/lib
LIB_VERSION   0x675
LIB_VERSION_NUMBER 6,7,5,6
LIBRARY_PATH  /home/entretenerse/lib/ImageMagick-6.7.5
LIBS          -lMagickCore -llcms -ltiff -lfreetype -ljpeg -lpng12 -lfontconfig -lXext -lXt -lSM -lICE -lX11 -lbz2 -lxml2 -lz -lm -lgomp -lpthread 
NAME          ImageMagick
PCFLAGS       -fopenmp
PREFIX        /home/entretenerse
QuantumDepth  16
RELEASE_DATE  2012-02-22
SHARE_PATH    /home/entretenerse/share/ImageMagick-6.7.5
SVN_REVISION  6851
TARGET_CPU    i686
TARGET_OS     linux-gnu
TARGET_VENDOR pc
VERSION       6.7.5
WEBSITE       http://www.imagemagick.org

Path: [built-in]

Name          Value
-------------------------------------------------------------------------------
NAME          ImageMagick

Re: help detecting misleading argumetns ofr Convert

Posted: 2012-02-22T12:12:01-07:00
by fmw42
I doubt this is the problem, but perhaps paperclip does not like IM running with OpenMP. You can recompile using --disable-openmp and see if that helps.

Also try without the ^ in the resize and see if that even works.

Re: help detecting misleading argumetns ofr Convert

Posted: 2012-02-22T12:28:15-07:00
by brutuscat
I was also thinking... I'm in a shared hosting, there is any way that somehow a misleading library is being picked up? I'm asking this because for what I've read the error in question seems to be from an earlier version of ImageMagick right?

So there is any recommended way of compiling it so I can be sure that it is always using the correct version of the libraries?

Re: help detecting misleading argumetns ofr Convert

Posted: 2012-02-22T13:11:45-07:00
by fmw42
brutuscat wrote:I was also thinking... I'm in a shared hosting, there is any way that somehow a misleading library is being picked up? I'm asking this because for what I've read the error in question seems to be from an earlier version of ImageMagick right?

So there is any recommended way of compiling it so I can be sure that it is always using the correct version of the libraries?
If there are multiple version of IM in the same location that could be a problem. But it does not explain why you can run it fine from the terminal and not with your other program.

However, the other program could be linked to another and possibly older version of IM.

You can try this in your terminal

type -a convert

or

which convert

The former may be better at telling your multiple versions of IM.

See if you really have multiple versions and where they reside. Then you can preface convert with the full path to the one you want to use presumably the more current one.

Re: help detecting misleading argumetns ofr Convert

Posted: 2012-02-23T03:06:49-07:00
by brutuscat
So No. I wasn't able to make this work correctly... Neither after setting the correct path of the ImageMagic binaries. I've tried almost everything.

So I ended up "manually" selecting the resize geometry based on the file's current width and height. I took @fmw42's "squareup" script and adapted it to my needs.

Thanks anyway! :D

Re: help detecting misleading argumetns ofr Convert

Posted: 2012-02-23T19:42:01-07:00
by anthony
brutuscat wrote:So this is what paperclip "says" it is executing, which it works fine if I copy paste it in my console:

Code: Select all

convert /tmp/stream20120222-16799-h6517r.txt[0]' -resize "90x90^" -unsharp 0x.7 -gravity center -extent 90x90 '/tmp/stream20120222-16799-h6517r20120222-16799-1yalfzi.gif'
You are missing single quotes at the start of the first filename!
EG: convert '/tmp/stream20120222-16799-h6517r.txt[0]' -resize "90x90^" ....