jtescher / carrierwave-imageoptimizer

This gem allows you to simply optimize CarrierWave images via jpegoptim or optipng.
https://rubygems.org/gems/carrierwave-imageoptimizer
MIT License
212 stars 33 forks source link

Compatibility with cloudinary_gem #10

Closed vasilakisfil closed 9 years ago

vasilakisfil commented 9 years ago

Is it working in combination with cloudinary/cloudinary_gem ? I have the following simple uploader:

class ImageUploader < CarrierWave::Uploader::Base
  include Cloudinary::CarrierWave
  include CarrierWave::ImageOptimizer

  process :optimize

  version :thumbnail do
    cloudinary_transformation width: 130, height: 150,
      crop: :thumb
  end
end

But I get the following error when I try to upload an image:

NoMethodError - undefined method `each' for nil:NilClass:
  cloudinary (1.0.78) lib/cloudinary/carrier_wave/process.rb:100:in `block in transformation'
  cloudinary (1.0.78) lib/cloudinary/carrier_wave/process.rb:61:in `each'
  cloudinary (1.0.78) lib/cloudinary/carrier_wave/process.rb:61:in `transformation'
  cloudinary (1.0.78) lib/cloudinary/carrier_wave/process.rb:135:in `format'
  cloudinary (1.0.78) lib/cloudinary/carrier_wave.rb:63:in `filename'
  carrierwave (0.10.0) lib/carrierwave/storage/abstract.rb:19:in `identifier'
  carrierwave (0.10.0) lib/carrierwave/uploader/proxy.rb:35:in `identifier'
  carrierwave (0.10.0) lib/carrierwave/mount.rb:312:in `write_identifier'
  carrierwave (0.10.0) lib/carrierwave/mount.rb:223:in `write_document_image_identifier'
  activesupport (4.1.5) lib/active_support/callbacks.rb:424:in `block in make_lambda'
  activesupport (4.1.5) lib/active_support/callbacks.rb:160:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:160:in `block in halting'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
  activesupport (4.1.5) lib/active_support/callbacks.rb:86:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:86:in `run_callbacks'
  activerecord (4.1.5) lib/active_record/callbacks.rb:302:in `create_or_update'
  activerecord (4.1.5) lib/active_record/persistence.rb:103:in `save'
  activerecord (4.1.5) lib/active_record/validations.rb:51:in `save'
  activerecord (4.1.5) lib/active_record/attribute_methods/dirty.rb:21:in `save'
  activerecord (4.1.5) lib/active_record/transactions.rb:268:in `block (2 levels) in save'
  activerecord (4.1.5) lib/active_record/transactions.rb:329:in `block in with_transaction_returning_status'
  activerecord (4.1.5) lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `block in transaction'
  activerecord (4.1.5) lib/active_record/connection_adapters/abstract/database_statements.rb:209:in `within_new_transaction'
  activerecord (4.1.5) lib/active_record/connection_adapters/abstract/database_statements.rb:201:in `transaction'
  activerecord (4.1.5) lib/active_record/transactions.rb:208:in `transaction'
  activerecord (4.1.5) lib/active_record/transactions.rb:326:in `with_transaction_returning_status'
  activerecord (4.1.5) lib/active_record/transactions.rb:268:in `block in save'
  activerecord (4.1.5) lib/active_record/transactions.rb:283:in `rollback_active_record_state!'
  activerecord (4.1.5) lib/active_record/transactions.rb:267:in `save'
   () home/vasilakisfil/.rvm/gems/ruby-2.1.4/bundler/gems/active_admin-99d76711783c/lib/active_admin/resource_controller/data_access.rb:159:in `block in save_resource'
  activesupport (4.1.5) lib/active_support/core_ext/object/try.rb:45:in `call'
  activesupport (4.1.5) lib/active_support/core_ext/object/try.rb:45:in `public_send'
  activesupport (4.1.5) lib/active_support/core_ext/object/try.rb:45:in `try'
   () home/vasilakisfil/.rvm/gems/ruby-2.1.4/bundler/gems/active_admin-99d76711783c/lib/active_admin/callbacks.rb:79:in `block (2 levels) in define_active_admin_callbacks'
   () home/vasilakisfil/.rvm/gems/ruby-2.1.4/bundler/gems/active_admin-99d76711783c/lib/active_admin/resource_controller/data_access.rb:158:in `save_resource'
   () home/vasilakisfil/.rvm/gems/ruby-2.1.4/bundler/gems/active_admin-99d76711783c/lib/active_admin/resource_controller/data_access.rb:181:in `block in update_resource'
  activesupport (4.1.5) lib/active_support/core_ext/object/try.rb:45:in `call'
  activesupport (4.1.5) lib/active_support/core_ext/object/try.rb:45:in `public_send'
  activesupport (4.1.5) lib/active_support/core_ext/object/try.rb:45:in `try'
   () home/vasilakisfil/.rvm/gems/ruby-2.1.4/bundler/gems/active_admin-99d76711783c/lib/active_admin/callbacks.rb:79:in `block (2 levels) in define_active_admin_callbacks'
   () home/vasilakisfil/.rvm/gems/ruby-2.1.4/bundler/gems/active_admin-99d76711783c/lib/active_admin/resource_controller/data_access.rb:180:in `update_resource'
  inherited_resources (1.5.1) lib/inherited_resources/actions.rb:45:in `update'
  actionpack (4.1.5) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (4.1.5) lib/abstract_controller/base.rb:189:in `process_action'
  actionpack (4.1.5) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (4.1.5) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
  activesupport (4.1.5) lib/active_support/callbacks.rb:113:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:113:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.5) lib/active_support/callbacks.rb:229:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:229:in `block in halting'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.5) lib/active_support/callbacks.rb:149:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
  activesupport (4.1.5) lib/active_support/callbacks.rb:229:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:229:in `block in halting'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.5) lib/active_support/callbacks.rb:86:in `call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:86:in `run_callbacks'
  actionpack (4.1.5) lib/abstract_controller/callbacks.rb:19:in `process_action'
  actionpack (4.1.5) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (4.1.5) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
  activesupport (4.1.5) lib/active_support/notifications.rb:159:in `block in instrument'
  activesupport (4.1.5) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.1.5) lib/active_support/notifications.rb:159:in `instrument'
  actionpack (4.1.5) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  actionpack (4.1.5) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
  activerecord (4.1.5) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (4.1.5) lib/abstract_controller/base.rb:136:in `process'
  actionview (4.1.5) lib/action_view/rendering.rb:30:in `process'
  actionpack (4.1.5) lib/action_controller/metal.rb:196:in `dispatch'
  actionpack (4.1.5) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
  actionpack (4.1.5) lib/action_controller/metal.rb:232:in `block in action'
  actionpack (4.1.5) lib/action_dispatch/routing/route_set.rb:82:in `call'
  actionpack (4.1.5) lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
  actionpack (4.1.5) lib/action_dispatch/routing/route_set.rb:50:in `call'
  actionpack (4.1.5) lib/action_dispatch/journey/router.rb:71:in `block in call'
  actionpack (4.1.5) lib/action_dispatch/journey/router.rb:59:in `each'
  actionpack (4.1.5) lib/action_dispatch/journey/router.rb:59:in `call'
  actionpack (4.1.5) lib/action_dispatch/routing/route_set.rb:678:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/rack/agent_hooks.rb:26:in `traced_call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/rack/browser_monitoring.rb:23:in `traced_call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/rack/developer_mode.rb:48:in `traced_call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:in `call'
  warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
  warden (1.2.3) lib/warden/manager.rb:34:in `catch'
  warden (1.2.3) lib/warden/manager.rb:34:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  rack (1.5.2) lib/rack/etag.rb:23:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  rack (1.5.2) lib/rack/conditionalget.rb:35:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  rack (1.5.2) lib/rack/head.rb:11:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  actionpack (4.1.5) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  actionpack (4.1.5) lib/action_dispatch/middleware/flash.rb:254:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
  rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  actionpack (4.1.5) lib/action_dispatch/middleware/cookies.rb:560:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  activerecord (4.1.5) lib/active_record/query_cache.rb:36:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  activerecord (4.1.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  activerecord (4.1.5) lib/active_record/migration.rb:380:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  actionpack (4.1.5) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.1.5) lib/active_support/callbacks.rb:82:in `run_callbacks'
  actionpack (4.1.5) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  actionpack (4.1.5) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  actionpack (4.1.5) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  better_errors (2.0.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (2.0.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (2.0.0) lib/better_errors/middleware.rb:57:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  actionpack (4.1.5) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  actionpack (4.1.5) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  railties (4.1.5) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.1.5) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.1.5) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.1.5) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.1.5) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.1.5) lib/rails/rack/logger.rb:20:in `call'
  quiet_assets (1.0.3) lib/quiet_assets.rb:23:in `call_with_quiet_assets'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  actionpack (4.1.5) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  rack (1.5.2) lib/rack/runtime.rb:17:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  activesupport (4.1.5) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  rack (1.5.2) lib/rack/lock.rb:17:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  actionpack (4.1.5) lib/action_dispatch/middleware/static.rb:64:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  rack-timeout (0.1.0) lib/rack/timeout.rb:84:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  honeybadger (1.16.5) lib/honeybadger/rack/error_notifier.rb:43:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  honeybadger (1.16.5) lib/honeybadger/rack/user_feedback.rb:24:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  honeybadger (1.16.5) lib/honeybadger/rack/user_informer.rb:13:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  railties (4.1.5) lib/rails/engine.rb:514:in `call'
  railties (4.1.5) lib/rails/application.rb:144:in `call'
  newrelic_rpm (3.9.6.257) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
  rack (1.5.2) lib/rack/content_length.rb:14:in `call'
  puma (2.9.2) lib/puma/server.rb:490:in `handle_request'
  puma (2.9.2) lib/puma/server.rb:361:in `process_client'
  puma (2.9.2) lib/puma/server.rb:254:in `block in run'
  puma (2.9.2) lib/puma/thread_pool.rb:92:in `call'
  puma (2.9.2) lib/puma/thread_pool.rb:92:in `block in spawn_thread'

Shouldn't be possible ?

vasilakisfil commented 9 years ago

Basically I want to run optimizations before saving the images to cloudinary cloud.

jtescher commented 9 years ago

Interesting. I don't see optimize in that stack trace. Any more information to help find the cause of the problem?

jtescher commented 9 years ago

Closing this due to inactivity. If you have any further issues, please reopen.