You can ask Cloudinary to return your image's metadata and colors, either while uploading or using our Admin API for already uploaded images.
Here's some more information regarding extracting image metadata in rails:
http://cloudinary.com/documentation/rails_image_upload#semantic_data_extraction
http://cloudinary.com/blog/api_for_extracting_semantic_image_data_colors_faces_exif_data_and_more
For server-side uploads you can use 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, just add :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 to your ActiveRecord model entity the following code for processing metadata returned by Cloudinary. 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
Comments
0 comments
Please sign in to leave a comment.