1

I'm trying to extract images from an Access database with php.

I can read the data, it gives me an hexadecimal string with a "\0" after every 254 chars so after a

$pic = str_replace("\0", '', $pic);
$pic = hex2bin($pic);

I get this:

00000000: 151c 1c00 0300 0000 0700 0100 1400 1b00  ................
00000010: ffff ffff 496d 6167 656d 0000 0105 0000  ....Imagem......
00000020: 0300 0000 0400 0000 4449 4200 5a17 0000  ........DIB.Z...
00000030: f5e8 ffff ac13 0300 2800 0000 e200 0000  ........(.......
00000040: df00 0000 0100 2000 0300 0000 7813 0300  ...... .....x...
00000050: c40e 0000 c40e 0000 0000 0000 0000 0000  ................
00000060: 0000 ff00 00ff 0000 ff00 0000 c2d6 dbff  ................
00000070: c9e0 e2ff c7db e0ff c3da dcff cbe2 e4ff  ................
00000080: c3dd ddff bbd5 d5ff bedb d8ff c2e2 ddff  ................
00000090: c0e2 dbff bee0 d9ff b7dc d2ff b1d6 ccff  ................
000000a0: a9ce c4ff a1c6 bcff 9dc3 b7ff 88af a0ff  ................
000000b0: 86ad 9eff 7fa8 99ff 7aa3 94ff 739c 8dff  ........z...s...
000000c0: 6e97 88ff 6792 83ff 6590 81ff 5986 76ff  n...g...e...Y.v.
000000d0: 5986 76ff 5986 76ff 5885 75ff 5685 75ff  Y.v.Y.v.X.u.V.u.

I think this is a bitmap with an OLE header, but I couldn't find what to do next. How can I save these, ideally as jpeg?

Edit: when I save the data to a file, no program I tried can view/identify the image. Also, none of the imagecreatefrom*() worked. I think I need to handle the header somehow.

  • Possible duplicate of [How can I convert all images to jpg?](https://stackoverflow.com/questions/14549446/how-can-i-convert-all-images-to-jpg) – June7 Jan 22 '18 at 20:06
  • These images are saved in attachment type field? Probably have to first extract file to external location then run code to convert. – June7 Jan 22 '18 at 20:09

0 Answers0