[Clipart] [Open Clip Art Library] No pictures?

Jon Phillips jon at rejon.org
Sun Aug 10 08:59:08 PDT 2008


Cool! Thanks for the code...that url below keeps cycling out...maybe
blocked by chinese GFW...

What kind of hit on the server does it take using Inkscape from
commandline?

Jon

On Sat, 2008-08-09 at 12:31 -0300, Valessio S Brito wrote:
> and url, index.php:
> 
> http://200.223.95.99/svg2png/?svg=http://openclipart.org/cchost/people/aurium/aurium_blue_iris.svg
> 
> 2008/8/9 Valessio S Brito <valessio at colivre.coop.br>:
> > Solution Inkscape+PHP in gallery InkscapeBrasil.org..
> > view code:
> >
> > ------- index.php -------------
> > <?
> > if ( $argc > 0 ) {
> >  $_GET = array (
> >    debug => 1,
> >    svg => $argv[1]
> >  );
> > }
> >
> > if ( $_GET['rm-cache'] == 1 ) {
> >  exec( "rm cache/*" );
> > }
> >
> > exec( "export LESSCLOSE='/usr/bin/lesspipe %s %s'" );
> > if ( $_GET['debug'] ) {
> >  echo '<pre>PWD: '.exec("pwd")."\nENV: ".exec("env")."\n";
> > } else {
> >  header('Content-Type: image/png');
> > }
> >
> > $svgURL = $_GET['svg'];
> >
> > if ( $_GET['debug'] ) {
> >  echo "SVG-URL: $svgURL\n";
> > }
> >
> > if ( ereg ('^http://', $svgURL) ) {
> >  $er = '[^-.a-zA-Z0-9]';
> >  $svg = 'cache/'. ereg_replace( $er, '_',  $svgURL ). '.svg';
> >  $png = 'cache/'. ereg_replace( $er, '_',  $svgURL ). '.png';
> > } else {
> >  if ( $_GET['debug'] ) {
> >    echo "URL Invalida\n\n";
> >  }
> >  readfile('url-invalida.png');
> >  exit;
> > }
> >
> > if ( $_GET['debug'] ) {
> >  echo "SVG: $svg\nPNG: $png\n";
> > }
> >
> > if ( file_exists($png) ) {
> >  if ( $_GET['debug'] ) {
> >    echo "PNG em Cache\n\n";
> >  }
> >  readfile($png);
> > }
> > else {
> >  /*
> >  // Get the SVG using PHP:
> >  // ...but is not workingo for some urls... :-(
> >  // php_network_getaddresses: getaddrinfo failed: Name or service not known
> >  if ( $_GET['debug'] ) { echo "Download SVG...\n"; }
> >  if ( @fopen($svgURL, 'r') ) {
> >    if ( ! $hSVG = fopen($svg, 'w') ) {
> >      if ( $_GET['debug'] ) { echo "Can't to create files\n\n"; }
> >      readfile('erro.png');
> >      exit;
> >    }
> >    if ( !fwrite( $hSVG, file_get_contents($svgURL) ) ) {
> >      if ( $_GET['debug'] ) { echo "Can't to write svg file\n\n"; }
> >      readfile('erro.png');
> >      exit;
> >    }
> >    fclose($hSVG);
> >  }
> >  else {
> >    if ( $_GET['debug'] ) { echo "Provavel 404\n\n"; }
> >    print readfile('url-invalida.png');
> >    exit;
> >  }
> >  */
> >  // Geting SVG with Wget:
> >  $saida0 = exec( "wget -q --no-check-certificate " .
> >                  escapeshellarg($svgURL) .
> >                  " -O $svg || echo ERROR" );
> >  if ( $_GET['debug'] ) {
> >    echo "SVG File Info: ". exec( "ls -lh ".$svg ) ."\n";
> >  }
> >  if ( $saida0 == 'ERROR' ) {
> >    if ( $_GET['debug'] ) { echo "Provavel 404\n\n"; }
> >    print readfile('url-invalida.png');
> >  }
> >  // Generating PNG:
> >  $imgSize = 80;
> >  $saida1 = exec("inkscape -z $svg -w ".($imgSize*2.3)." -e $png 2>&1
> > || echo ERROR when try export PNG");
> >  if ( $_GET['debug'] ) {
> >    echo "PNG File Info: ". exec( "ls -lh ".$png ) ."\n";
> >  }
> >  $saida2 = exec("convert $png -trim $png || echo ERROR when try trim");
> >  $w = exec("identify -format %w $png");
> >  $h = exec("identify -format %h $png");
> >  if ( $w > $h ) {
> >    $bigger = $w;
> >  } else {
> >    $bigger = $h;
> >  }
> >  $nW = round( ($w/$bigger) * $imgSize );
> >  $nH = round( ($h/$bigger) * $imgSize );
> >  if ( $_GET['debug'] ) {
> >    echo "\nOriginal PNG size: ${w}x${h}   Resize to: ${nW}x${nH}\n";
> >  }
> >  $saida2 = exec("convert -size ${imgSize}x${imgSize} xc:transparent
> > -gravity Center -draw 'image Over 0,0 $nW,$nH $png' $png 2>&1");
> >  # unlink( $svg ); // delete file svg
> >  if ( $_GET['debug'] ) {
> >    echo "\nSaida Inkscape: \"$saida1\"\n\nSaida ImageMagick: \"$saida2\"\n";
> >  }
> >  if ( $saida2 != '' ) {
> >    if ( $_GET['debug'] ) {
> >      echo "Erro...\n\n";
> >    }
> >    readfile('erro.png');
> >  } else {
> >    if ( $_GET['debug'] ) {
> >      echo "Gerado!\n\n";
> >    }
> >    readfile($png);
> >  }
> > }
> >
> > if ( $_GET['debug'] ) {
> >  echo '</pre>';
> >  phpinfo();
> > }
> > ?>
> > ---------------end svg.php---------------
> >
> >
> >
> > .ValessioBrito
> >
> >
> > 2008/8/7 Jon Phillips <jon at rejon.org>:
> >> Hi Val, yes, we don't have thumbnails. If you know php, would be great
> >> to get assistance.
> >>
> >> On Sat, 2008-02-02 at 14:37 +0000, noreply at openclipart.org wrote:
> >>> Hi, I have only just registered with you and many images can not be seen just a little box with a red cross in the cenrte?
> >>> Val
> >>> _______________________________________________
> >>> clipart mailing list
> >>> clipart at lists.freedesktop.org
> >>> http://lists.freedesktop.org/mailman/listinfo/clipart
> >> --
> >> Jon Phillips
> >> San Francisco, CA + Guangzhou + Beijing
> >> GLOBAL +1.415.830.3884
> >> CHINA +86.1.360.282.8624
> >> jon at rejon.org
> >> http://www.rejon.org
> >> IM/skype: kidproto
> >> Jabber: rejon at gristle.org
> >> IRC: rejon at irc.freenode.net
> >>
> >> _______________________________________________
> >> clipart mailing list
> >> clipart at lists.freedesktop.org
> >> http://lists.freedesktop.org/mailman/listinfo/clipart
> >>
> >
> >
> >
> > --
> > .ValessioBrito - http://valessiobrito.info
> >
> 
> 
> 
-- 
Jon Phillips
San Francisco, CA + Guangzhou + Beijing
GLOBAL +1.415.830.3884
CHINA +86.1.360.282.8624
jon at rejon.org
http://www.rejon.org
IM/skype: kidproto
Jabber: rejon at gristle.org
IRC: rejon at irc.freenode.net




More information about the clipart mailing list