# Attachment\_fu: save to a default format

**URL:** <https://www.ruby-forum.com/t/attachment-fu-save-to-a-default-format/158085>\
**Category:** Rails\
**Created:** [January 19, 2009, 8:51am UTC](https://www.ruby-forum.com/t/attachment-fu-save-to-a-default-format/158085 "2009-01-19T08:51:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [January 19, 2009, 8:51am UTC](https://www.ruby-forum.com/t/attachment-fu-save-to-a-default-format/158085/1 "2009-01-19T08:51:47Z")

</div>

Hi, would anyone have any advices on the next?

I allow users to upload images to my app. I’m using attachment\_fu and  
MiniMagick.  
There’s two things that I’d like to do:

1- No matter what format the original file is I’d like to save it in jgp  
format.  
2- I want to keep all images limited to say 1000px width, so resize if  
they are bigger.

Is there a way to do that without much hassle?

Thanks.

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [January 19, 2009, 2:46pm UTC](https://www.ruby-forum.com/t/attachment-fu-save-to-a-default-format/158085/2 "2009-01-19T14:46:27Z")

</div>

Resizing is a basic feature, take a look at the README. Format  
transformation, on the other hand, is more difficult and is not a  
known feature of attachemnt\_fu…

Cheers, Sazima

On Jan 19, 5:51 am, comopasta Gr [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [January 20, 2009, 1:18am UTC](https://www.ruby-forum.com/t/attachment-fu-save-to-a-default-format/158085/3 "2009-01-20T01:18:17Z")

</div>

Here’s an example of how to do what you want with Rmagick (probably  
works in  
principle with mini magick, but not sure):

> <https://github.com/kete/kete/blob/3ae3c179f86943ccccaf5a15d8b5590a28c0ae6e/lib/resize_as_jpeg_when_necessary.rb>

It’s a module we mix in to monkey patch (i.e. redefine methods locally)  
attachment\_fu’s built in processor code for Rmagick in the Kete app (  
[http://kete.net.nz](http://kete.net.nz)).

Cheers,  
Walter

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [January 20, 2009, 6:51am UTC](https://www.ruby-forum.com/t/attachment-fu-save-to-a-default-format/158085/4 "2009-01-20T06:51:16Z")

</div>

Hi, thanks for the comments!

This is a great piece of information.

Regards.
