[Ilugc] to truncate a long rectangular image into severalsmaller imageusing php and gd

  • From: smal@xxxxxxxxxxx (Mahalingam Subramaniam)
  • Date: Mon Jan 25 10:23:25 2010

hello
Sorry, but i am expecting the solution to be in php with gd. I have modified 
the php script to enable it to deliver the desired output but, it still outputs 
the syntax error.
the sample script is enclosed as an attachment
with regards
s.mahalingam
-- Original Message --
From: Kenneth Gonsalves <lawgon@xxxxxxxxxxxxxxx>
To: "ILUG-C" <ilugc@xxxxxxxxxxxxx>
Date: Sat, 23 Jan 2010 16:10:13 +0530
Subject: Re: [Ilugc] to truncate a long rectangular image into several smaller
        imageusing php and gd
On Friday 22 Jan 2010 12:46:10 pm Mahalingam Subramaniam wrote:

the aim is to cut and append one below other a long rectangular image of
 4500*80 pixels png image using php script with g

just to experiment - cut a 1000 by 100 image into 10 and pasted in a fresh 
image 100 by 1000
#!/usr/bin/python
from PIL import Image
#create image in red 1000x100
am = Image.new('RGB',(1000,100),'red')
#create image in black 100x1000
im = Image.new('RGB',(100,1000))
#slice first image and paste into second
for x in range(0,1000,100):
    sm = am.crop((x,0,x+100,100))
    ym = im.paste(sm,(0,x,100,x+100))
im.show()
I'm sure perl guys can do it in one line ;-)
-- 
regards
kg
http://lawgon.livejournal.com
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

-------------- next part --------------
<?php
#$file="count_chars.txt";
$file="co3.txt";
$handle=fopen($file, 'r');
#$theData = "$readchar($handle,filesize($file))";
#$theData = "$readchar($handle,820)";

$A=0;
$G=0;
$C=0;
$T=0;
#$question=0;
#$dash =0;

$img = imagecreate(4000,80);
$white = imagecolorallocate($img, 255,255,255);
$green=imagecolorallocate($img, 0, 128, 0);
$black=imagecolorallocate($img, 0, 0, 0);
$red=imagecolorallocate($img, 255, 0, 0);
$blue=imagecolorallocate($img, 0, 0, 255);

$x1=40;
$y1=40;
$x2=43;
$y2=80;

$x3=40;
$y3=160;
$x4=43;
$y4=80;

$x5=40;
$y5=280;
$x6=43;
$y6=80;

$x7=40;
$y7=400;
$x8=43;
$y8=80;

while(!feof($handle))

{ $readchar=fgetc($handle);
  $readchar=strtoupper($readchar);
#$img = imagecreate(367,80);
 if($readchar=='A')

  {
#    echo($readchar);
   # $A++
    if ( $A++ >= 100 ) {
    then
    imagefilledrectangle($img, $x1, $y1, $x2, $y2, $green);
    $x1=$x1+6;
    $x2=$x2+6;
}

    else
    If ( $A++ <= 101 ) {
    then
    imagefilledrectangle($img, $x3, $y3, $x4, $y4, $green);
    $x3=$x3+6;
    $x4=$x4+6;
    
    else
    If ( $A++ <= 201 ) {
    then
    imagefilledrectangle($img, $x5, $y5, $x6, $y6, $green);
    $x5=$x6+6;
    $x6=$y6+6;
}
    else
    If ( $A++ <= 301 ) {
    then
    imagefilledrectangle($img, $x7, $y7, $x8, $y8, $green);
    $x7=$x7+6;
    $x8=$x8+6;
    }
}

fclose($handle);

header("Content-type: image/png");
imagepng($img);
imagedestroy($img);

?>


Other related posts:

  • » [Ilugc] to truncate a long rectangular image into severalsmaller imageusing php and gd - Mahalingam Subramaniam