0

I am able to view the .bin image files using display command in ImageMagick.

display -size 512x512 -depth 32 -equalize gray:<filename>

I was able to convert it to jpg format and then display on a webpage. But I need to display the file without converting it to jpg.

Using php exec(), it was possible to display the file when running the php file on terminal but not on apache web server. Is there a way to display the .bin image file on a web page? Please help me as I have been trying this for many days...

emcconville
  • 23,800
  • 4
  • 50
  • 66
Seletrix
  • 3
  • 3
  • What is a `.bin` image? Usually, `.bin` is used for CD image like `.iso`? Is this a graphical file like `.png`? – ssc-hrep3 Jun 10 '16 at 11:08
  • yes it is a graphical file.It is possible to convert it to jpg/png etc formats – Seletrix Jun 10 '16 at 11:10
  • 1
    I have never heard of graphical `.bin` images. And so does the "Image Format Support" chart on Wikipedia. You should only use image formats for web development, which are widely supported. This means, a conversion of your images would be most preferable. http://stackoverflow.com/q/183831/3233827 – ssc-hrep3 Jun 10 '16 at 11:18

1 Answers1

1

No.

The gray: protocol will only output an image data blob. There is no image headers, and various important meta-data (like size, depth, & etc) are not communicated/transported.

Even display requires you to, at minimum, specify size + depth before it can read the .bin file.

However, if you can communicate the depth & width to the web browser, you can rebuild the image with Javascript & <canvas> tag. But that would be labor intensive, and the load-time results would be unpleasant for end-users.

emcconville
  • 23,800
  • 4
  • 50
  • 66
  • Thanks for helping me out. Is it possible to call a script that executes the display command from a web page? – Seletrix Jun 10 '16 at 13:51
  • Also no. Well. If the bin resource _is_ served from the HTTP service, then you can show people the `display` commands to view remote resources. Or even write an application & [register a URL schema](https://msdn.microsoft.com/en-us/library/aa767914.aspx), but that's a lot of work. – emcconville Jun 10 '16 at 14:23
  • Is it feasible/worth to write a browser plugin/java applet (or something else) to be able to display the .bin file on a web browser? (The .bin file contains raw image data) – Seletrix Jun 15 '16 at 08:55
  • Feasible, yes. Worth it, no. Honestly, just create a "web-only preview" for browser display. Modern image formats (png/webp) are very good at compression / fault tolerance. If you attempt a plugin you may discover that the raw data will be [clamped to 8-bit color depth](https://developer.mozilla.org/en-US/docs/Web/API/ImageData). – emcconville Jun 15 '16 at 13:03