SVG thumbnailing not scaling

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
immewnity
Posts: 12
Joined: 2011-05-14T14:25:03-07:00
Authentication code: 8675308

SVG thumbnailing not scaling

Post 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?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: SVG thumbnailing not scaling

Post 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
immewnity
Posts: 12
Joined: 2011-05-14T14:25:03-07:00
Authentication code: 8675308

Re: SVG thumbnailing not scaling

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: SVG thumbnailing not scaling

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: SVG thumbnailing not scaling

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
immewnity
Posts: 12
Joined: 2011-05-14T14:25:03-07:00
Authentication code: 8675308

Re: SVG thumbnailing not scaling

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: SVG thumbnailing not scaling

Post 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?
immewnity
Posts: 12
Joined: 2011-05-14T14:25:03-07:00
Authentication code: 8675308

Re: SVG thumbnailing not scaling

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: SVG thumbnailing not scaling

Post by fmw42 »

what version of IM are you using?
immewnity
Posts: 12
Joined: 2011-05-14T14:25:03-07:00
Authentication code: 8675308

Re: SVG thumbnailing not scaling

Post by immewnity »

fmw42 wrote:what version of IM are you using?
6.6.9-6 (April 26, 2011)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: SVG thumbnailing not scaling

Post 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.
immewnity
Posts: 12
Joined: 2011-05-14T14:25:03-07:00
Authentication code: 8675308

Re: SVG thumbnailing not scaling

Post by immewnity »

Yup, adding density worked! Thanks!
Post Reply