Page 2 of 2

Re: Path points?

Posted: 2010-06-01T17:22:37-07:00
by immortal26
Here is the SVG... give it time it takes a while to load .. it's huge! note: right click save as
http://www.kgcore.com/mvp/stadium/florida/final.svg

Here is the rest of the php code so you can see how things are going.

Code: Select all

<?php

$path = "mvp/stadium/florida/";

$text = "david jones";
$bm = "bitmap/";
$font = "font/trace.TTF";
$bg = "back/Florida.png";
$png = ".png";
$jpg = ".jpg";
$fwidth = 720;
$fheight = 227;
$fx = 550;
$fy = 345;
$skewx = 348;
$skewy = 315;


$text = strtoupper($text);

$final = "convert -font ".$font." -pointsize 90 -kerning 10 -gravity center -size 1000x1000 xc:none -annotate ".$skewx."x".$skewy."+0+0 '".$text."' final".$png;
exec($final, $result);

$final = "convert final".$png." to final.svg";
exec($final, $result);

$xml = simplexml_load_file('final.svg');

list($width, $height) = getimagesize('final'.$png);

$coords = "";

$i=0;
$final = 'convert -size '.$width.'x'.$height.' xc:none ';
$none = 0;
foreach ($xml->circle as $s) {
	if ($s['fill']!='none') {
		if ($i == 2) {
			$rbm = rand(1,4);
			$final .= $bm.'bm'.$rbm.$png.' -geometry +'.$s['cx'].'+'.$s['cy'].' -composite ';
			$i=0;			
		}
		else {
			$i++;
		}
	}
}
$final .= 'final'.$png;

exec($final, $result);

$final = "convert ".$bg." final".$png." -geometry +".$fx."+".$fy." -composite final.pdf";

exec($final, $result);

$remove = "rm final".$png;
exec($remove, $result);
$remove2 = "rm final.svg";
//exec($remove2, $result);

header("Location: final.pdf");
exit;

?>
I will try the dot's out in a few... the blur will be added once i get everything finished :P

Re: Path points?

Posted: 2010-06-01T17:34:14-07:00
by snibgo
$final = "convert final".$png." to final.svg";

??

Re: Path points?

Posted: 2010-06-01T18:23:58-07:00
by snibgo
Hmmm ... okay. That 45 MB SVG defines a canvas of 1000x1000, and draws a circle radius one on every single pixel. Most are blank, and you are picking out the others, the ones used to draw the font. Looking at final.png with Gimp, I see that each letter is made from dashes, and each dash is 1 or 2 pixels wide and 5 or 6 long. Each of these pixels is being picked up as a "circle".

You have filled each dash with band members. Well, as you divide by 3, you have typically 2 or 3 band members per dash. You might add a debug to your code, to count how many band members are drawn.

I quite like this effect.

If you want only 1 band member per dash, you need to simplify, perhaps like this:

Code: Select all

"%IMG%convert" ^
  -font trace.ttf ^
  -pointsize 90 -kerning 10 -gravity center -size 1000x1000 ^
  xc:Black -fill White -annotate 550x348+0+0 "david jones" ^
  -threshold 1%% ^
  -morphology Correlate ^
  "3: -1 -1 -1  -1 1 -  - - -" ^
  final.png
(This is Windows script, of course, so you'll have to convert to php.)

This draws white dashes on a black background, then erodes each dash to the top-left white pixel. You can convert to svg, and then should search for non-black istead of non-none.

Re: Path points?

Posted: 2010-06-01T20:14:23-07:00
by anthony
For drawing multiple symbols on a list of coordinates you are better off using a loop to create IM commands.

One set of examples of doing this (using draw, rather than compose) is in http://www.imagemagick.org/Usage/draw/#symbols

Re: Path points?

Posted: 2010-06-02T10:37:32-07:00
by immortal26
snibgo wrote:Hmmm ... okay. That 45 MB SVG defines a canvas of 1000x1000, and draws a circle radius one on every single pixel. Most are blank, and you are picking out the others, the ones used to draw the font. Looking at final.png with Gimp, I see that each letter is made from dashes, and each dash is 1 or 2 pixels wide and 5 or 6 long. Each of these pixels is being picked up as a "circle".

You have filled each dash with band members. Well, as you divide by 3, you have typically 2 or 3 band members per dash. You might add a debug to your code, to count how many band members are drawn.

I quite like this effect.

If you want only 1 band member per dash, you need to simplify, perhaps like this:

Code: Select all

"%IMG%convert" ^
  -font trace.ttf ^
  -pointsize 90 -kerning 10 -gravity center -size 1000x1000 ^
  xc:Black -fill White -annotate 550x348+0+0 "david jones" ^
  -threshold 1%% ^
  -morphology Correlate ^
  "3: -1 -1 -1  -1 1 -  - - -" ^
  final.png
(This is Windows script, of course, so you'll have to convert to php.)

This draws white dashes on a black background, then erodes each dash to the top-left white pixel. You can convert to svg, and then should search for non-black istead of non-none.
This didn't seem to work for me, still gave me the same amount of band members... but one of my colleagues is creating a single pixel font for me and we already tested a couple of letters and it worked beautifully.

So I guess the only thing left is preserving transparency and original colors.
I think it has something to do with creating the canvas for the bandmembers, I believe it's creating a RGB canvas and then when trying to overlay that on the cmky jpg image the transparency is lost... so converting the cmky jpg to a png to preserve the transparency I lose color.
There is no embeded ICC profile in the jpg or the bitmap png's so what would be my next step on that.
Getting so close to a cool script.

Re: Path points?

Posted: 2010-06-02T20:45:43-07:00
by anthony
snibgo wrote:Hmmm ... okay. That 45 MB SVG defines a canvas of 1000x1000, and draws a circle radius one on every single pixel. Most are blank, and you are picking out the others, the ones used to draw the font. Looking at final.png with Gimp, I see that each letter is made from dashes, and each dash is 1 or 2 pixels wide and 5 or 6 long. Each of these pixels is being picked up as a "circle".
If you get a huge SVG full of circles, it means you have not installed autotrace Library!

The work around is to convert the image using IM and the autotrace command.
http://www.imagemagick.org/Usage/transform/#edge_vector

This gets you a vector outline of the image.

HOWEVER a TTF font defines it characters in terms of vector outlines! So what you really want to do is use some type of TTF to vector converter to get the points involved. IM can not do that!