# Attachment\_fu, Paperclip, & S3

**URL:** <https://www.ruby-forum.com/t/attachment-fu-paperclip-s3/147499>\
**Category:** Rails\
**Created:** [September 2, 2008, 3:45pm UTC](https://www.ruby-forum.com/t/attachment-fu-paperclip-s3/147499 "2008-09-02T15:45:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chunkyslink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f0a364/32.png) [@chunkyslink](https://www.ruby-forum.com/u/chunkyslink)\
**Post date:** [September 2, 2008, 3:45pm UTC](https://www.ruby-forum.com/t/attachment-fu-paperclip-s3/147499/1 "2008-09-02T15:45:11Z")

</div>

For various reasons, I made a git branch and installed Paperclip in  
place of attachment\_fu. Paperclip works great except that images seem to  
have lost some quality; edges have gone a little too jaggy to be able to  
drop attachment\_fu just yet. After a post on the Paperclip Google Group,  
someone suggested the :convert\_options could be passed additional  
attributes, like ‘quality’, and could make a difference. I’ve attempted  
to pass these options across, but, they don’t seem to work; I’m probably  
sending them incorrectly because visually obvious options, like  
‘rotate’, clearly don’t do anything (or throw any errors, either). Does  
anyone know what I’m doing wrong here (?);

# Attempt no.1

has\_attached\_file :avatar, :convert\_options =\> { :rotate =\> “-rotate  
-90” },  
:styles =\> {  
:thumb\_45 =\> ‘45x45#’…

# Attempt no.2

:convert\_options =\> { :rotate =\> “-rotate ‘-90’” }

# Attempt no.3

:convert\_options =\> { :rotate =\> “-90” }

# Attempt no.4

:convert\_options =\> { :rotate =\> -90 }

Also, attachment\_fu was really easy to set up with S3. I followed a  
tutorial from Railsforum (1.), and got it working first time. I’ve read  
through the Paperclip docs (2.), but I find the RDocs format to be  
pretty inaccessible for a newbie (does ‘+s3\_credentials+’ equate to  
:s3\_credentials, as a symbol?), so I haven’t worked out how to use  
Paperclip with S3 or found a tutorial from which I could probably learn  
how to do so. Does anyone know, a) how to include the S3 options and  
configure paperclip to send images over to S3, and, b) if I’ll get good  
results (searching the Paperclip google groups suggests that there could  
be some issues with paperclip & S3)?

1. [http://railsforum.com/viewtopic.php?id=17815](http://railsforum.com/viewtopic.php?id=17815)

2. [http://dev.thoughtbot.com/paperclip/](http://dev.thoughtbot.com/paperclip/)

Any help is tres appreciated (that’s an understatement).

p.s. another dev (not working on the app anymore) set up some European  
buckets, and I want to delete them - but the S3Browser keeps telling me  
‘Redirected to Nowhere’ whenever I try to do so - any ideas on how to  
fix that?.

---

<div class="post-metadata">

**Author:** ![chunkyslink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f0a364/32.png) [@chunkyslink](https://www.ruby-forum.com/u/chunkyslink)\
**Post date:** [October 1, 2008, 8:00pm UTC](https://www.ruby-forum.com/t/attachment-fu-paperclip-s3/147499/2 "2008-10-01T20:00:19Z")

</div>

here’s how to use convert\_options from the comments in paperclip.rg:

has\_attached\_file :avatar, :styles =\> { :large =\> “300x300”, :negative  
=\> “100x100” }  
:convert\_options =\> {  
:all =\> “-strip”,  
:negative =\> “-negate”  
}

On Sep 2, 8:45 am, Neil C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![chunkyslink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f0a364/32.png) [@chunkyslink](https://www.ruby-forum.com/u/chunkyslink)\
**Post date:** [October 1, 2008, 9:05pm UTC](https://www.ruby-forum.com/t/attachment-fu-paperclip-s3/147499/3 "2008-10-01T21:05:46Z")

</div>

Keith N. wrote:

> here’s how to use convert\_options from the comments in paperclip.rg:
> 
> has\_attached\_file :avatar, :styles =\> { :large =\> “300x300”, :negative  
> =\> “100x100” }  
> :convert\_options =\> {  
> :all =\> “-strip”,  
> :negative =\> “-negate”  
> }
> 
> On Sep 2, 8:45 am, Neil C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Thanks Keith, I’m almost 100% done with implementing Paperclip, I just  
need to mock the calls to S3 and make at a background worker for pushing  
to S3 instead of tying up mongresl (the later won’t be so easy).

I mentioned the aliasing issue to the guys at thoughtbot - they  
suggested trying a different cropping method. I found that ‘scale’  
seemed to give a much nicer cropping conversion quality (had to dig in  
to the paperclip.rb to get at it, I just couldn’t work out the convert  
options), so they pushed it in as the default for Paperclip. It doesn’t  
seem to work well when converting PNG to jpg, but that’s something I can  
live with. They also implemented buckets on a per environment basis  
using the yml config. So I’m really happy with it now, much easier than  
attachment fu.

---

<div class="post-metadata">

**Author:** ![chunkyslink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f0a364/32.png) [@chunkyslink](https://www.ruby-forum.com/u/chunkyslink)\
**Post date:** [October 2, 2008, 2:05pm UTC](https://www.ruby-forum.com/t/attachment-fu-paperclip-s3/147499/4 "2008-10-02T14:05:46Z")

</div>

On Wed, Oct 1, 2008 at 12:05 PM, Neil C. \<  
removed\_email\_address@domain.invalid\> wrote:

> > On Sep 2, 8:45 am, Neil C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
> 
> Thanks Keith, I’m almost 100% done with implementing Paperclip, I just  
> need to mock the calls to S3 and make at a background worker for pushing  
> to S3 instead of tying up mongresl (the later won’t be so easy).
> 
> …

Both backgroundjob and spawn are great ways to do this. I use both to  
great  
affect to do the same thing.

–  
Benjamin C.  
[http://railskits.com/](http://railskits.com/) - Ready-made Rails code  
[http://catchthebest.com/](http://catchthebest.com/) - Team-powered recruiting  
[http://www.bencurtis.com/](http://www.bencurtis.com/) - Personal blog

---

<div class="post-metadata">

**Author:** ![chunkyslink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f0a364/32.png) [@chunkyslink](https://www.ruby-forum.com/u/chunkyslink)\
**Post date:** [October 2, 2008, 2:25pm UTC](https://www.ruby-forum.com/t/attachment-fu-paperclip-s3/147499/5 "2008-10-02T14:25:46Z")

</div>

Benjamin C. wrote:

> On Wed, Oct 1, 2008 at 12:05 PM, Neil C. \<  
> removed\_email\_address@domain.invalid\> wrote:
> 
> > > On Sep 2, 8:45 am, Neil C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
> > 
> > Thanks Keith, I’m almost 100% done with implementing Paperclip, I just  
> > need to mock the calls to S3 and make at a background worker for pushing  
> > to S3 instead of tying up mongresl (the later won’t be so easy).
> > 
> > …
> 
> Both backgroundjob and spawn are great ways to do this. I use both to  
> great  
> affect to do the same thing.
> 
> –  
> Benjamin C.  
> [http://railskits.com/](http://railskits.com/) - Ready-made Rails code  
> [http://catchthebest.com/](http://catchthebest.com/) - Team-powered recruiting  
> [http://www.bencurtis.com/](http://www.bencurtis.com/) - Personal blog

Thanks. I was thinking it would mean storing locally and moving to S3 in  
the background; someone seems to have taken the same approach in a  
thread on the Paperclip google group (although there’s 0 responses so I  
don’t know how they got on with it);

[http://groups.google.com/group/paperclip-plugin/browse\_thread/thread/8af52cc25cd97d02/05221d1a7254601d?lnk=gst&q=background#05221d1a7254601d](http://groups.google.com/group/paperclip-plugin/browse_thread/thread/8af52cc25cd97d02/05221d1a7254601d?lnk=gst&q=background#05221d1a7254601d)

There’s an interesting presentation on starling, workling, spawn etc  
(among other background workers) which got me thinking about going with  
something other than backgroundrb;

> **[Railsconf Berlin 04.09.2008](https://www.slideshare.net/purzelrakete/railsconf-berlin-04092008-presentation?src=embed)**
>
> PLAY/TYPE Starling + Workling: simple distributed ...

…but I just got off the phone with an engine yard account manager for  
my app and I’m waiting to see what their devs have to say about.  
Apparently they have quite a few apps pushing content to S3, so it’s  
something they can help out with; I’m not sure how far they can get in  
separating out processes to async processes (I have tons of specs, but  
still), but maybe I won’t need to write it all from scratch.

I think this would make a pretty good screencast for someone to make  
(and charge for). I’d pay $5 - 10 to see how a pro installs a user  
avatar (probably the most common image upload), sets all the right  
defaults for paperclip, makes it all secure, sets up decent spec  
coverage, asyncs it with S3 (again, which good spec coverage) and makes  
it manageable over dev, test, staging, production environments. I’ve  
done most of it, but, I would still pay to watch an expert implement it  
using best practices.
