# Problem with image rotate RMagick

**URL:** <https://www.ruby-forum.com/t/problem-with-image-rotate-rmagick/129025>\
**Category:** Ruby\
**Created:** [February 13, 2008, 5:02pm UTC](https://www.ruby-forum.com/t/problem-with-image-rotate-rmagick/129025 "2008-02-13T17:02:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nephish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8e7dd6/32.png) [@nephish](https://www.ruby-forum.com/u/nephish)\
**Post date:** [February 13, 2008, 5:02pm UTC](https://www.ruby-forum.com/t/problem-with-image-rotate-rmagick/129025/1 "2008-02-13T17:02:48Z")

</div>

I cant seem to get an image rotate right.  
I am using RMagick to do this.

the source image file is transparent with a single red line.

image = Magick::Image.read(‘public/images/line.png’).first  
image.rotate!(degrees.to\_i)

the problem is that when i do this, every pixel that was transparent  
becomes black.

The docs said that this would be the case, but i cannot seem to find  
where to override this to preserve the transparency.

thanks for any tips.

sk

---

<div class="post-metadata">

**Author:** ![nephish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8e7dd6/32.png) [@nephish](https://www.ruby-forum.com/u/nephish)\
**Post date:** [February 13, 2008, 5:15pm UTC](https://www.ruby-forum.com/t/problem-with-image-rotate-rmagick/129025/2 "2008-02-13T17:15:44Z")

</div>

Shawn B. wrote:

> I cant seem to get an image rotate right.  
> I am using RMagick to do this.
> 
> the source image file is transparent with a single red line.
> 
> image = Magick::Image.read(‘public/images/line.png’).first  
> image.rotate!(degrees.to\_i)
> 
> the problem is that when i do this, every pixel that was transparent  
> becomes black.
> 
> The docs said that this would be the case, but i cannot seem to find  
> where to override this to preserve the transparency.
> 
> thanks for any tips.
> 
> sk

Try setting the image’s background color to “none” before calling  
rotate.

---

<div class="post-metadata">

**Author:** ![nephish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8e7dd6/32.png) [@nephish](https://www.ruby-forum.com/u/nephish)\
**Post date:** [February 13, 2008, 5:31pm UTC](https://www.ruby-forum.com/t/problem-with-image-rotate-rmagick/129025/3 "2008-02-13T17:31:09Z")

</div>

worked perfect,  
thanks much

sk
