I have an :xxx image processor, and I have two styles in the model :big and :thumb.
How I can process with :xxx only the :thumb image leaving the :big image untouched ?
I recently had a similar problem and found this solution on a message board. Hope it helps!
has_attached_file :screenshot,
:default_style => :full,
:styles => {
:full => "280x210",
:cropped => { :processors => [:screenshot_crop] }
}
By default, the Rake task refreshes all thumbnails. Keep in mind that it won't touch / process the original image.
You could have a look at the Rakefile and the Attachment class and modify to allow you to specify a specific thumbnail size, but the current design assumes that you want to take the original and redo all thumbnails from the original.
Add this code to your paperclip.rake file:
desc "Reprocesses your attachments style (set CLASS, ATTACHMENT and STYLE)"
task :style => :environment do
module JustForOneDay
NAME = ENV['STYLE']
end
module ::Paperclip
class Attachment
def post_process_styles #:nodoc:
@styles.each do |name, args|
if JustForOneDay::NAME == name
begin
raise RuntimeError.new("Style #{name} has no processors defined.") if args[:processors].blank?
@queued_for_write[name] = args[:processors].inject(@queued_for_write[:original]) do |file, processor|
Paperclip.processor(processor).make(file, args, self)
end
rescue PaperclipError => e
log("An error was received while processing: #{e.inspect}")
(@errors[:processing] ||= []) << e.message if @whiny
end
end
end
end
end
end
for_all_attachments do |instance, name|
result = instance.send(name).reprocess!
end
end
end
Tested with Paperclip 2.3.1.1
In Paperclip 2.3.3 this should be:
def post_process_styles #:nodoc:
styles.each do |name, style|
if JustForOneDay::NAME == name
begin
raise RuntimeError.new("Style #{name} has no processors defined.") if style.processors.blank?
@queued_for_write[name] = style.processors.inject(@queued_for_write[:original]) do |file, processor|
Paperclip.processor(processor).make(file, style.processor_options, self)
end
rescue PaperclipError => e
log("An error was received while processing: #{e.inspect}")
(@errors[:processing] ||= []) << e.message if @whiny
end
end
end
end
It's easy, just go to attachment.rb file in your paperclip version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With