Hi, I found interesting functions (The code comes from ResourceSpace DAM, opensource) that were able to convert indd files into jpeg.
Maybe that could give you ideas to adapt it for Gallery2...
if ($extension=="indd" && !isset($newfile))
{
$indd_thumb = extract_indd_thumb ($file);
if ($indd_thumb!="no")
{
base64_to_jpeg( $indd_thumb, $target);
if (file_exists($target)){$newfile = $target;}
}
hook("indesign");
}
function extract_indd_thumb ($filename) {
$source = file_get_contents($filename);
$xmpdata_start = strrpos($source,"<xap:Thumbnails");
$xmpdata_end = strrpos($source,"</xap:Thumbnails>");
$xmplength = $xmpdata_end-$xmpdata_start;
$xmpdata = substr($source,$xmpdata_start,$xmplength+12);
$regexp = "/<xapGImg:image>.+<\/xapGImg:image>/";
preg_match ($regexp, $xmpdata, $r);
if (isset($r['0'])){
$indd_thumb = strip_tags($r['0']);
$indd_thumb = str_replace("#xA;","",$indd_thumb);
return $indd_thumb;} else {return "no";}
}
> Here we take a short part of the file, containing all the pieces of information we need to convert it into jpg
function base64_to_jpeg( $imageData, $outputfile )
{
$jpeg = fopen( $outputfile, "wb" ) or die ("can't open");
fwrite( $jpeg, base64_decode( $imageData ) );
fclose( $jpeg );
}
> Here is the converting part
A.Wern
Posts: 16504
Development on G2 is essentially ceased. All development efforts are currently focused on G3.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here