# Setting image resolution with Rmagick

**URL:** <https://www.ruby-forum.com/t/setting-image-resolution-with-rmagick/99275>\
**Category:** Rails\
**Created:** [July 21, 2006, 12:52pm UTC](https://www.ruby-forum.com/t/setting-image-resolution-with-rmagick/99275 "2006-07-21T12:52:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ant\_Peacocke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/779978/32.png) [@Ant\_Peacocke](https://www.ruby-forum.com/u/Ant_Peacocke)\
**Post date:** [July 21, 2006, 12:52pm UTC](https://www.ruby-forum.com/t/setting-image-resolution-with-rmagick/99275/1 "2006-07-21T12:52:40Z")

</div>

Hi

Has anyone had success with setting image resolution with Rmagick.

I am resizing an uploaded image with Rmagick, problem is it keeps the  
original images resolution and I want to change it to 72dpi.

\<\<\<\<\<\< code example \>\>\>\>\>\>\>\>\>\>

# these are the various techniques I have tried when and after reading

the file, trying any or all of them does not work.  
image\_render = Magick::Image.read(temp\_path){self.density=72}[0]

image\_render.units=Magick::PixelsPerInchResolution  
image\_render.x\_resolution=72  
image\_render.y\_resolution=72

# I also tried this when writing the image to disk

image\_render.write(temp\_path){self.quality = 90,  
self.units=Magick::PixelsPerInchResolution, self.density = 72}

\<\<\<\<\<\< code example : end\>\>\>\>\>\>\>\>\>\>

Any thoughts/ideas would be much appreciated

Best regards  
Ant

–  
Ant Peacocke

[www.levelsystems.net](http://www.levelsystems.net)  
T: + 33 (0) 8 70 46 63 37  
M: + 33 (0) 6 09 81 06 00

---

<div class="post-metadata">

**Author:** ![Ant\_Peacocke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/779978/32.png) [@Ant\_Peacocke](https://www.ruby-forum.com/u/Ant_Peacocke)\
**Post date:** [December 28, 2006, 5:41am UTC](https://www.ruby-forum.com/t/setting-image-resolution-with-rmagick/99275/2 "2006-12-28T05:41:01Z")

</div>

Has anyone figured out this image resolution problem?  
“convert -density xx in.eps out.png” works as expected but I can’t  
figure out how to do this with RMagick.  
Is this an RMagick bug?

Thanks,  
Quinn

Ant Peacocke wrote:

> Hi
> 
> Has anyone had success with setting image resolution with Rmagick.
> 
> I am resizing an uploaded image with Rmagick, problem is it keeps the  
> original images resolution and I want to change it to 72dpi.
> 
> \<\<\<\<\<\< code example \>\>\>\>\>\>\>\>\>\>
> 
> # these are the various techniques I have tried when and after reading
> 
> the file, trying any or all of them does not work.  
> image\_render = Magick::Image.read(temp\_path){self.density=72}[0]
> 
> image\_render.units=Magick::PixelsPerInchResolution  
> image\_render.x\_resolution=72  
> image\_render.y\_resolution=72
> 
> # I also tried this when writing the image to disk
> 
> image\_render.write(temp\_path){self.quality = 90,  
> self.units=Magick::PixelsPerInchResolution, self.density = 72}
> 
> \<\<\<\<\<\< code example : end\>\>\>\>\>\>\>\>\>\>
> 
> Any thoughts/ideas would be much appreciated
> 
> Best regards  
> Ant
> 
> –  
> Ant Peacocke
> 
> [www.levelsystems.net](http://www.levelsystems.net)  
> T: + 33 (0) 8 70 46 63 37  
> M: + 33 (0) 6 09 81 06 00
