Solved

PHP to perl-Help !

Posted on 2001-06-13
3
199 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
This article discusses four methods for overlaying images in a container on a web page
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…
The viewer will learn how to dynamically set the form action using jQuery.

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now