Solved

PHP to perl-Help !

Posted on 2001-06-13
3
206 Views
Last Modified: 2008-03-06
Hi

I found the following programs in PHP and I want to understand them to convert them to perl. Does any one know how to convert them please. Thanks
ImageCreate ??
ImageColorAllocate ??
ImageFilledRectangle ??
etc ??



/* create GIF file */

$im - ImageCreate (420,420);
$white = ImageColorAllocate ($im,255,255,255);
$black = ImageColorAllocate ($im,0,0,0);
$red = ImageColorAllocate ($im,255,10,10);
$green = ImageColorAllocate ($im,10,255,10);
$blue = ImageColorAllocate ($im,10,10,255);
$yellow = ImageColorAllocate ($im,255,255,0);
$y1 = ImageColorAllocate ($im,255,255,0);
$y2 = ImageColorAllocate ($im,255,220,0);
$y3 = ImageColorAllocate ($im,255,150,0);
$y4 = ImageColorAllocate ($im,255,20,0);

/* draw a legend */

ImageString ($im,5,10,20,"X county, state", $black);
ImageFilledRectangle ($im,10,280,20,290,$y1)
ImageFilledRectangle ($im,110,280,120,290,$y2)
ImageFilledRectangle ($im,210,280,220,290,$y3)
ImageFilledRectangle ($im,310,280,320,290,$y4)
ImageFilledRectangle ($im,2,10,300,less than 5,000",$black)
etc...
0
Comment
Question by:nawaf
3 Comments
 
LVL 4

Expert Comment

by:ykf2000
ID: 6189113
I think you'll have to have a graphics library in Perl to do this.
0
 
LVL 3

Accepted Solution

by:
rycamor earned 100 total points
ID: 6189267
The code above is part of an extension to PHP to interface with the GD graphics library ( www.boutell.com/gd ). This is not part of the core language, so there will not be a direct mapping to similar Perl functions.

Perl has a library for handling GD, though, called GD.pm, which you can see at http://search.cpan.org/search?dist=GD . Be aware that you also have to install GD itself on your system.


It should be pretty easy to identify which functions do the same as the above PHP functions you quote, because they derive from the GD API.

I will mention also, that with PHP or Perl, the latest version of the GD image handler will NOT produce gif images, only PNG, Jpeg and others. This is because GD itself now doesn't handle gif output, due to copyright issues with Unisys, the patent holder for LZW compression. If you want to create a gif image, you need version 1.3 of GD and an older version of GD.pm.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6419187
It's time to clean up this topic area and that means taking care of this question. Your options at this point are:

1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.

2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

3.  Ask Community Support to help split points between participating experts.  Just comment here with details.

4.  Delete the question because it is of no value to you or to anyone else.  To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

If you elect for option 2, 3 or 4, just post comment with details here and I'll take it from there.  We also request that you review any other open questions you might have and update/close them.  Display all your question history from your Member Profile to view details.

PLEASE DO NOT AWARD THE POINTS TO ME.

____________________________________________



Hi Experts:

In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question.  Likewise, you can also suggest that I PAQ or delete the question.

Experts, please do not add further "answer" information to this question.  I will be back in about one week to finalize this question.

Thank you everyone.

Moondancer :)
Community Support Moderator @ Experts Exchange

P.S.  REGARDING POINTS, Guidelines and more:  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp  
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What if i make webbased alternative for MS Access 5 99
jQuery force form POST 7 84
MySQL Persistent Connections 10 30
Convert php array to comma seperated list 19 31
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question