Page 1 of 1

SVG thumbnailing not scaling

Posted: 2011-05-14T14:44:06-07:00
by immewnity
Hi,

I'm using ImageMagick on my wiki, and am trying to thumbnail an SVG file using

Code: Select all

"/usr/include/ImageMagick/bin/convert" -background none -thumbnail $widthx$height\! $input PNG:$output
with the $variables automatically filled in with MediaWiki. However, all attempts at resizing result in simply an enlarged version of the originally thumbnailed PNG file, not a scaled version. Is something wrong with the command line query?

Re: SVG thumbnailing not scaling

Posted: 2011-05-14T16:04:48-07:00
by fmw42
try putting your input right after the convert. it may or may not help

also try replacing $widthx$height\! with ${width}x${height}\! as the x may be read as part of widthx, ie. as $widthx as the first variable

have you checked to see that width and height variables are actually the desired values?

I am confused -- is your input svg or png?

If svg, does

convert -list format

contain

SVG SVG rw+ Scalable Vector Graphics

Re: SVG thumbnailing not scaling

Posted: 2011-05-14T16:47:27-07:00
by immewnity
fmw42 wrote:try putting your input right after the convert. it may or may not help

also try replacing $widthx$height\! with ${width}x${height}\! as the x may be read as part of widthx, ie. as $widthx as the first variable

have you checked to see that width and height variables are actually the desired values?

I am confused -- is your input svg or png?

If svg, does

convert -list format

contain

SVG SVG rw+ Scalable Vector Graphics
I put the input right after the convert, and nothing was changed. I put the brackets in, and I got an error. And yes, width and height are the desired values. SVG is the input format, and I sent an e-mail to my host to either check that or enable shell access.

EDIT: Alright, the host claims that SVG is supported, so I have no idea at the moment.

Re: SVG thumbnailing not scaling

Posted: 2011-05-14T17:35:03-07:00
by fmw42
Are you using an IM API or perhaps PHP exec command?

If so, what is your exact command? Perhaps someone more familiar with your API or PHP may be able to find an error in your syntax. In command line mode, the {} are necessary to keep $widthx from being interpreted as a variable rather than $width. Sorry I am only familiar with the command line mode of IM.

Re: SVG thumbnailing not scaling

Posted: 2011-05-15T05:28:28-07:00
by anthony
When using SVG IM has two choices. RSVG (a delegate library, and the prefered choice) or as intenal MSVG rendered that converts SVG to MVG the IM -draw commands.

See IM Examples, Draw, SVG, for details...
http://www.imagemagick.org/Usage/draw/#svg

Re: SVG thumbnailing not scaling

Posted: 2011-05-15T06:14:00-07:00
by immewnity
I think I'm using a PHP exec command, as it's in a PHP file under PHP coding. My exact command is what I posted, plus what MediaWiki needs:

Code: Select all

$wgSVGConverters = array(
    'ImageMagick' => '"/usr/include/ImageMagick/bin/convert" -background none -thumbnail ${width}x${height}\! $input PNG:$output',
);
I tried putting the curly brackets in, but got an error:

Code: Select all

Error creating thumbnail: convert: negative or zero image size `/home/pidginet/public_html/wiki/images/3/34/Pikachu_-_Dream_World.svg' @ error/resize.c/ResizeImage/2554.
I also tried using RSVG, but it just wouldn't work.

Re: SVG thumbnailing not scaling

Posted: 2011-05-15T09:59:36-07:00
by fmw42
{} may need to be {$width}x{$height} in PHP. but I don't see any PHP exec command, so I am not sure what to tell you. Some PHP or whatever API you are using expert will likely need to help you. You can always try replacing the variables with the actual values in a test case and see if that works. Try making things as simple as possible to track down where it is failing. Can you run your command on the command line? Do you have permissions set up properly for files and does PHP know where IM is located?

Re: SVG thumbnailing not scaling

Posted: 2011-05-15T12:20:57-07:00
by immewnity
fmw42 wrote:{} may need to be {$width}x{$height} in PHP. but I don't see any PHP exec command, so I am not sure what to tell you. Some PHP or whatever API you are using expert will likely need to help you. You can always try replacing the variables with the actual values in a test case and see if that works. Try making things as simple as possible to track down where it is failing. Can you run your command on the command line? Do you have permissions set up properly for files and does PHP know where IM is located?
It's definitely reading the image sizes; I'll change it and the thumbnail will change accordingly. So, somehow ImageMagick isn't thumbnailing the SVG correctly.

Re: SVG thumbnailing not scaling

Posted: 2011-05-15T13:26:25-07:00
by fmw42
what version of IM are you using?

Re: SVG thumbnailing not scaling

Posted: 2011-05-15T13:54:05-07:00
by immewnity
fmw42 wrote:what version of IM are you using?
6.6.9-6 (April 26, 2011)

Re: SVG thumbnailing not scaling

Posted: 2011-05-15T14:44:43-07:00
by fmw42
I am not an expert on svg, but perhaps you can skip the thumbnail step by specifying the density for the output from the svg when converting to png, or specify the output size you want in the svg commands.

Re: SVG thumbnailing not scaling

Posted: 2011-05-15T16:37:45-07:00
by immewnity
Yup, adding density worked! Thanks!