SVG + wand-py + ImageMagick "scaling" issue.

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
streetlogics
Posts: 1
Joined: 2013-10-08T14:52:59-07:00
Authentication code: 6789

SVG + wand-py + ImageMagick "scaling" issue.

Post by streetlogics »

I have detailed my issue on StackOverflow - http://stackoverflow.com/questions/1925 ... ling-issue , so if you are a member / want some points and know the answer, feel free to post there, otherwise I'll keep an eye out here. Here are the details:

I'm using wand-py (0.3.3) and ImageMagick(versions below) in an application to customize designs from source SVGs. I'm currently running into an issue with different versions of ImageMagick returning rather different results, and I'm hoping somebody out there in Python / django land has an idea.

The source svg looks like this:
Image

Using ImageMagick 6.6.2-6 2012-08-17 Q16, the cropped / slightly scaled output looks like this (not perfect, but not terrible):
Image

However, using ImageMagick 6.6.9-7 2012-08-17 Q16, the output looks like this:
Image

The actual call I'm making is simply:

Code: Select all

with WandImage(blob = self.cover_binary, resolution = 300) as img:
    img.type = self.png_image_type #truecolor
    img.depth = self.png_image_depth #8
    img.resize(self.png_width, self.png_height)
    self.png_output = img.make_blob('png')
I've tried tons of variations of img.resize() with different blur and filter settings, (blur values between 0 and 1, filter values of none, triangle, point, lanczos, lanczossharp), but I'm just not able to get the preview rendering with the small line detail. I'm at my wits end and about to go with a solution that I don't like, and am hoping somebody out there might be able to give me some insight on what I'm missing here. It already took me a few hours just to realize that ImageMagick is the culprit since that's literally the only thing different between my local box running the older version and the staging box that has the newer version, and I've spent more than a few hours now tinkering with different settings and going through my workflow to re-render things (which takes ~30-60 seconds each time).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: SVG + wand-py + ImageMagick "scaling" issue.

Post by fmw42 »

try setting the equivalent of -filter point and -interpolation nearestneighbor with -resize.

or probably better (supersampling method)

set the svg density 4 times larger, then resize by 1/4 ( note you need to set the density before reading the svg file)

If that fails perhaps you should provide a link to the original svg file
Post Reply