You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there, recently we went through a Carrierwave + carrierwave_backgrounder update:
Before:
carrierwave 1.3.2
carrierwave_backgrounder 0.4.3
After:
carrierwave 3.0.5
carrierwave_backgrounder 1.0.2
Amongst many other things that were an issue, we noticed that base image processing was not working after updating. For example, using an uploader class similar to this:
class AvatarUploader < BaseImageUploader
include ::CarrierWave::Backgrounder::Delay
include CarrierWave::MiniMagick
include ApplicationUploader::StripExif
*** Snip lots of other code ***
# Process files as they are uploaded:
process resize_to_limit: [2048, 1024]
process :auto_rotate_base
# Create different versions of your uploaded files:
version :profile do
process resize_to_limit: [200, 200]
process :auto_rotate_profile
end
version :thumb, from_version: :profile do
process resize_to_limit: [60, 45]
end
private
def auto_rotate_base
warn 'AUTO ROTATE BASE'
manipulate! do |img|
img.auto_orient
img = yield(img) if block_given?
img
end
end
def auto_rotate_profile
warn 'AUTO ROTATE PROFILE'
manipulate! do |img|
img.auto_orient
img = yield(img) if block_given?
img
end
end
Excuse the different process functions here for auto rotate. In our code they are the same but it helped with debug logging here. There is a StripExif one as well in the included module but it's basically just another process function. BaseImageUploader is just a class that inherits from ApplicationUploader::Base while specifying a content_type_allowlist. When Carrierwave is used by itself without backgrounder or prior to version 3/backgrounder 1.0.2, the base processing of the resize to 2048x1024 and auto_rotate ran fine. After upgrading, these base image processors no longer run.
I think this is a change in recent Carrierwave versions that recreate_versions! does not apply processing to the base image. We've been using a fork for us of carrierwave_backgrounder where we have switched lib/backgrounder/workers/process_asset_mixin.rb to use cache! instead which seems to be both processing the base image as well as versions.
It may be a bit clearer to see with some logging. I enable MiniMagick debug logging with an initializer that has MiniMagick.logger.level = Logger::DEBUG if Rails.env.development? in it. With the current carrierwave_backgrounder 1.0.2, the logs look like this:
QuieterProcessAssetWorker by the way is a worker class of ours that inherits from CarrierWave::Workers::ProcessAsset and has some error catching, no real changes beyond that. So in this log, note that "AUTO ROTATE BASE" is not called/shown and the resize to 2048,1024 does not happen.
Here is a log with our fork/branch where the base resizing/auto rotate occurs as it should:
Note that "AUTO ROTATE BASE" is in the log and the base image resizing is done as expected.
So at this point I'm asking if anyone else noticed this issue, and if you're open to a PR to have these changes merged in. I should say that we primarily use remote_X_url to start the process here. We don't use direct assignment via assigning a file to the mounted uploader, but I just tested it and it is the same situation/issue/fix as above. When I was debugging carrierwave 3.0.5, the call stack that finally arrived at the image processor functions came through download! and then cache! in carrierwave, so even though it looks a bit odd to me to call cache! to process everything, it was the only way I saw to have both the base image processing done as well as the versions.
Hi there, recently we went through a Carrierwave + carrierwave_backgrounder update:
Before:
After:
Amongst many other things that were an issue, we noticed that base image processing was not working after updating. For example, using an uploader class similar to this:
Excuse the different process functions here for auto rotate. In our code they are the same but it helped with debug logging here. There is a StripExif one as well in the included module but it's basically just another process function. BaseImageUploader is just a class that inherits from
ApplicationUploader::Base
while specifying acontent_type_allowlist
. When Carrierwave is used by itself without backgrounder or prior to version 3/backgrounder 1.0.2, the base processing of the resize to 2048x1024 and auto_rotate ran fine. After upgrading, these base image processors no longer run.I think this is a change in recent Carrierwave versions that
recreate_versions!
does not apply processing to the base image. We've been using a fork for us of carrierwave_backgrounder where we have switchedlib/backgrounder/workers/process_asset_mixin.rb
to usecache!
instead which seems to be both processing the base image as well as versions.It may be a bit clearer to see with some logging. I enable MiniMagick debug logging with an initializer that has
MiniMagick.logger.level = Logger::DEBUG if Rails.env.development?
in it. With the currentcarrierwave_backgrounder
1.0.2, the logs look like this:QuieterProcessAssetWorker by the way is a worker class of ours that inherits from
CarrierWave::Workers::ProcessAsset
and has some error catching, no real changes beyond that. So in this log, note that "AUTO ROTATE BASE" is not called/shown and the resize to 2048,1024 does not happen.Here is a log with our fork/branch where the base resizing/auto rotate occurs as it should:
Note that "AUTO ROTATE BASE" is in the log and the base image resizing is done as expected.
So at this point I'm asking if anyone else noticed this issue, and if you're open to a PR to have these changes merged in. I should say that we primarily use
remote_X_url
to start the process here. We don't use direct assignment via assigning a file to the mounted uploader, but I just tested it and it is the same situation/issue/fix as above. When I was debugging carrierwave 3.0.5, the call stack that finally arrived at the image processor functions came throughdownload!
and thencache!
in carrierwave, so even though it looks a bit odd to me to callcache!
to process everything, it was the only way I saw to have both the base image processing done as well as the versions.Comparison URL
https://github.com/lardawge/carrierwave_backgrounder/compare/master...HiMamaInc:carrierwave_backgrounder:fix/process_asset?expand=1
Let me know what you think and if you think this would be appropriate for a PR. Thanks!
The text was updated successfully, but these errors were encountered: