vector density on read #15

Closed
bf4 opened this Issue Jul 24, 2014 · 4 comments

Projects

None yet

3 participants

@bf4
Member
bf4 commented Jul 24, 2014

Issue by hynkle
Saturday Jun 04, 2011 at 19:16 GMT
Originally opened as #25


I'm trying to convert a vector image to a raster image of a larger size, let's say 4x larger. Suppose just running convert img.svg img.png gives you a 100x100 image.

With ImageMagick's convert command, the conversion with enlargement would look like:

convert -density 288 img.svg img.png

Where 288 is of course 4x the default density of 72. And that works beautifully, resulting in the desired 400x400 image without the ugly artifacts you'd get from upsampling a 100x100 raster image to 400x400 (which is indeed why I'm using a vector image for the original in the first place).

But what I would have thought was the corresponding RMagick code:

image = Magick::Image.read('img.svg'){self.density = 144}.first
image.write('img.png')

... results in the same 100x100 image you'd get by just running convert img.svg img.png. Moreover, the image reports its density as "72x72" as though I hadn't supplied anything in read's block.

Am I simply approaching this problem wrong, or this a bug?

@bf4
Member
bf4 commented Jul 24, 2014

Comment by gucki
Tuesday Aug 16, 2011 at 15:23 GMT


I'm having exactly the same problem. Have you already been able to solve/ workaround it? :)

@bf4
Member
bf4 commented Jul 24, 2014

Comment by gucki
Tuesday Aug 16, 2011 at 15:25 GMT


I just now I found that this code works perfectly fine for me:

Magick::Image.read(filename) { self.density = "300x300" }.first

My fault was to not the the density on reading but later on, which does not work.

@Koronen
Koronen commented Sep 7, 2014

Candidate for closing?

@ioquatix
ioquatix commented Sep 7, 2014

Appears to be solved.

@ioquatix ioquatix closed this Sep 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment