Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting density doesn't appear to work #227

Closed
dkniffin opened this issue Oct 22, 2015 · 3 comments
Closed

setting density doesn't appear to work #227

dkniffin opened this issue Oct 22, 2015 · 3 comments

Comments

@dkniffin
Copy link

I'm trying to write some code that will take in an svg, resize it up, and output a png.

source svg file

This works fine using imagemagick's convert command:

convert -density 600 -sample 1600x1600 circle.svg out.png

convert_out

But when I use rmagick to do the same thing:

image = Magick::Image.read("oval.svg"){|a| a.density = "600"}.first
image.sample! 100
image.write("out.png")

I get pixelation problems
rmagick_out

I'm pretty sure the root problem here is that rmagick isn't respecting the density attribute properly.

This issue has appeared in a bunch of places around the web, but I've yet to find a solution that works:

@tamagokun
Copy link

Also having density issues. Trying to output an image at something other than 72 dpi, and nothing seems to work. I've tried self.density x_resolution y_resolution and resample and none of them changed the output dpi.

@tamagokun
Copy link

Need to specify the units beforehand! This bugged the crap out of me for weeks..

Something like this should work..

image = Magick::Image.read("oval.svg") {
  self.units = Magick::PixelsPerInchResolution
  self.density = "600"
}.first

@Watson1978
Copy link
Member

If at least one argument is given to the sample method, its value means scale.

 * @overload sample(scale)
 *   @param scale [Numeric] You can use this argument instead of specifying the desired width and
 *     height. The percentage size change. For example, 1.25 makes the new image 125% of the size of
 *     the receiver. The scale factor 0.5 makes the new image 50% of the size of the receiver.

So, image.sample! 100 resize to 10000% size. Looks for me that it is not same with covert command sample.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants