Solved

PHP to perl-Help !

Posted on 2001-06-13
3
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Set a time limit on Wordpress Cookie function. 3 48
Export Data from MySql Using PHP 16 67
Testrail - Active Directory integration. 4 35
phpmyadmin memory error 55 92
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

734 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