An Idea for supporting Indesign type (.indd)

Antwan Wern

Joined: 2010-07-15
Posts: 13
Posted: Mon, 2010-07-19 09:15

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

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Mon, 2010-07-19 22:41

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