0

In my application I sync users image uploaded as photo field in the LDAP, I am using NET::LDAP for the same.

the object returned for the image field is of type Net::BER::BerIdentifiedArray, I can convert it to Net::BER.

My question is how do I extract the type of image(jpeg/gif/bmp etc) while creating a image file from the binary response given by the LDAP.

Ross
  • 1,562
  • 1
  • 15
  • 26

1 Answers1

1

You'll need something to decode the binary data into an image. RMagick is a Ruby wrapper for ImageMagick that should do the trick. Specifically, Image.from_blob will read image data from a string in memory.

From there, this answer shows image.format will tell you the format.

Community
  • 1
  • 1
Nick Veys
  • 23,458
  • 4
  • 47
  • 64