You can ask Cloudinary to return your image's metadata and colors in a response either while uploading or while using our Admin API for already-uploaded images.
For more information regarding extracting image metadata in Rails, please refer to this blog post.
For server-side uploads you can use the following: cloudinary_transformation :image_metadata=>true
.
For example:
class PictureUploader < CarrierWave::Uploader::Base include Cloudinary::CarrierWave process :convert => 'png' cloudinary_transformation :image_metadata=>true # ... end
For client-side uploads, simply add the parameter :image_metadata=>true
to the cl_image_upload_tag
.
For example:
cl_image_upload_tag(:image_id, :image_metadata=>true).
To access the returned metadata after uploading, you can add the following code for processing metadata returned by Cloudinary to your ActiveRecord model entity. Please make sure after_save
is placed after the mount_uploader
definition:
after_save :check_metadata def check_metadata if self.picture.present? && self.picture.metadata.present? exif = self.picture.metadata["image_metadata"] # ... end end
For more information on the CarrierWave integration, please refer to the CarrierWave integration reference.
Comments
0 comments
Please sign in to leave a comment.