How to get an image's EXIF information using CarrierWave?

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:

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
  # ...

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"]
      # ...
Have more questions? Submit a request


Powered by Zendesk