# Setting image resolution with Rmagick

**URL:** <https://www.ruby-forum.com/t/setting-image-resolution-with-rmagick/99290>\
**Category:** Ruby\
**Created:** [July 21, 2006, 3:38pm UTC](https://www.ruby-forum.com/t/setting-image-resolution-with-rmagick/99290 "2006-07-21T15:38:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ant](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85e7bf/32.png) [@ant](https://www.ruby-forum.com/u/ant)\
**Post date:** [July 21, 2006, 3:38pm UTC](https://www.ruby-forum.com/t/setting-image-resolution-with-rmagick/99290/1 "2006-07-21T15:38:25Z")

</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
