Using PHP to generate images in alternate colors

I have a PNG image of a black silhouette graphic with
softened edges against a transparent background.
Can I use PHP to generate this image in alternate colors
(allowing the black graphic to be displayed in a color other than
black)?

AngryCloud posted in macromedia.dreamweaver:
> I have a PNG image of a black silhouette graphic with
softened
> edges against a transparent background.
>
> Can I use PHP to generate this image in alternate colors
> (allowing the black graphic to be displayed in a color
other than
> black)?
I have no experience with this, but I was just poking around
in the GD
references and found a comment on imagefill() that might
help:
http://us.php.net/manual/en/function.imagefill.php
Comment:
http://us.php.net/manual/en/function.imagefill.php#81873
Or you may need to work with some of the other alpha
functions.
Mark A. Boyd
Keep-On-Learnin' :)

Similar Messages

  • How use PHP to read image files from a folder and display them in Flex 3 tilelist.

    Hello. I need help on displaying images from a folder dynamically using PHP and display it on FLEX 3 TileList. Im currently able to read the image files from the folder but i don't know how to display them in the TileList. This is my current code
    PHP :
    PHP Code:
    <?php
    //Open images directory
    $imglist = '';
    $dir = dir("C:\Documents and Settings\april09mpsip\My Documents\Flex Builder 3\PHPTEST\src\Assets\images");
    //List files in images directory
    while (($file = $dir->read()) !== false)
    if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
    echo "filename: " . $file . "\n";
    $dir->close();
    ?>
    FLEX 3 :
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="pic.send();">
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    import mx.events.FlexEvent;
    import mx.rpc.events.FaultEvent;
    import mx.events.ItemClickEvent;
    import mx.rpc.events.ResultEvent;
    public var image:Object;
    private function resultHandler(event:ResultEvent):void
    image = (event.result);
    ta1.text = String(event.result);
    private function faultHandler(event:FaultEvent):void
    ta1.text = "Fault Response from HTTPService call:\n ";
    ]]>
    </mx:Script>
    <mx:TileList x="31" y="22" initialize="init();" dataProvider = "{image}" width="630" height="149"/>
    <mx:String id="phpPicture">http://localhost/php/Picture.php</mx:String>
    <mx:HTTPService id="pic" url="{phpPicture}" method="POST"
    result="{resultHandler(event)}" fault="{faultHandler(event)}"/>
    <mx:TextArea x="136" y="325" width="182" height="221" id="ta1" editable="false"/>
    <mx:Label x="136" y="297" text="List of files in the folder" width="182" height="20" fontWeight="bold" fontSize="13"/>
    </mx:Application>
    Thanks. Need help as soon as possbile. URGENT.

    i have made some changes, in the php part too, and following is the resulting code( i tried it, and found that it works.):
    PHP Code:
    <?php
    echo '<?xml version="1.0" encoding="utf-8"?>';
    ?>
    <root>
    <images>
    <?php
    //Open images directory
    $dir = dir("images");
    //List files in images directory
    while (($file = $dir->read()) !== false)
    if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
    echo "<image>" . $file . "</image>"; // i expect you to use the relative path in $dir, not C:\..........
    //$dir->close();
    ?>
    </images>
    </root>
    Flex Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute"
    creationComplete="callPHP();">
    <mx:Script>
    <![CDATA[
    import mx.rpc.http.HTTPService;
    import mx.controls.Alert;
    import mx.events.FlexEvent;
    import mx.rpc.events.FaultEvent;
    import mx.events.ItemClickEvent;
    import mx.collections.ArrayCollection;
    import mx.rpc.events.ResultEvent;
    [Bindable]
    private var arr:ArrayCollection = new ArrayCollection();
    private function callPHP():void
    var hs:HTTPService = new HTTPService();
    hs.url = 'Picture.php';
    hs.addEventListener( ResultEvent.RESULT, resultHandler );
    hs.addEventListener( FaultEvent.FAULT, faultHandler )
    hs.send();
    private function resultHandler( event:ResultEvent ):void
    arr = event.result.root.images.image as ArrayCollection;
    private function faultHandler( event:FaultEvent ):void
    Alert.show( "Fault Response from HTTPService call:\n " );
    ]]>
    </mx:Script>
    <mx:TileList id="tilelist"
    dataProvider="{arr}">
    <mx:itemRenderer>
    <mx:Component>
    <mx:Image source="images/{data}" />
    </mx:Component>
    </mx:itemRenderer>
    </mx:TileList>
    </mx:Application>

  • How to upload an image in a directory using PHP code generated by Dreamweaver?

    I have created a dynamic website with Dreamweaver and PHP, i have also created a insertform page using dreamweaver's 'Record Insertion Form Wizard' i have a field named prod_img in my MySQL database and on my form but this is a text field and i have to enter the path of the image directory to display it but this needs to have the image in the directory, i want to add a browse file field so that the image uploads to the directory by PHP.
    My code is as follows:
    <?php require_once('../Connections/dwtltd.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO special_offers (spec_img, spec_head, spec_desc, spec_call, spec_price, spec_rtn) VALUES (%s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['spec_img'], "text"),
                           GetSQLValueString($_POST['spec_head'], "text"),
                           GetSQLValueString($_POST['spec_desc'], "text"),
                           GetSQLValueString($_POST['spec_call'], "text"),
                           GetSQLValueString($_POST['spec_price'], "text"),
                           GetSQLValueString($_POST['spec_rtn'], "text"));
      mysql_select_db($database_dwtltd, $dwtltd);
      $Result1 = mysql_query($insertSQL, $dwtltd) or die(mysql_error());
      $insertGoTo = "../specialoffers.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
    mysql_select_db($database_dwtltd, $dwtltd);
    $query_insertRS = "SELECT * FROM special_offers ORDER BY spec_id ASC";
    $insertRS = mysql_query($query_insertRS, $dwtltd) or die(mysql_error());
    $row_insertRS = mysql_fetch_assoc($insertRS);
    $totalRows_insertRS = mysql_num_rows($insertRS);
    ?>
    <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
      <table align="center" cellpadding="5">
        <tr valign="baseline">
          <td align="right" nowrap="nowrap">Add Image:</td>
          <td><span id="sprytextfield1">
          <input type="text" name="spec_img" value="" size="32" />
          <span class="textfieldRequiredMsg">A value is required.</span></span></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Offer Heading:</td>
          <td><input type="text" name="spec_head" value="" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Offer Description:</td>
          <td><input type="text" name="spec_desc" value="" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Phone:</td>
          <td><input type="text" name="spec_call" value="" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Price:</td>
          <td><input type="text" name="spec_price" value="" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">RTN:</td>
          <td><input type="text" name="spec_rtn" value="" size="32" /></td>
        </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right"> </td>
          <td><input type="submit" value="Insert record" /></td>
        </tr>
      </table>
      <input type="hidden" name="MM_insert" value="form1" />
    </form>
    Help greatly appreciated.
    I have googled, yahooed, binged etc etc and tried many tutorials but nothing goes in my favor please do not suggest to search on search engines or websites.

    Years and months later, apparently Dreamweaver CC 2014 has a "File" Form object that has a text box and Browse button.  Now I'm looking for the part that does the actual upload (which is why I wound up here).  I'm sure by now you have found a way to resolve your issue, but there it is....

  • Php to generate numbers spreadsheet

    there is a pear package (http://pear.php.net/package/SpreadsheetExcelWriter) that uses php to generate excel spreadsheets. could this be done with numbers? anyone have any idea what would have to change to use numbers instead of excel?

    that explains quite a bit, thanks.
    this could be worth my while though. i've never used numbers and rarely use excel. is anyone aware of any obvious reasons that using numbers for this purpose might be better?
    i have modified a version of the spreadsheet excel writer and making graphs is possible but very tedious and extremely limited, could it be that numbers make it easier to do this?
    also excel is tricky with the way it stores dates and some of it's formatting information, and a wild little conversion process as to take place to convert from mysql format to a format excel will display properly. maybe numbers might improve this?
    finally, the only way i've discovered to effectively upload information from an excel spreadsheet is to first export it to csv (mostly because of this date and formatting issues) then upload it. obviously it'd make more sense to an end-user not have to export a file to a different format. i was hoping numbers might be able to keep a consistent file format instead.
    like you said, the structure is not documented, so i doubt you'd know the answers here for sure. but do have any incline at all that any of these points would be improved by using numbers?
    thanks again for your time

  • Generating images on the fly to use as backgrounds for components

    I am creating an application that has an input number slider with a background image. I would like to change the background image on the slider based on its position (as chosen by the user) using a partial trigger.
    I have successfully been able to do update the background images if I have these images inside of my "Web Content" folder within my JDeveloper project. Instead, I would like to be able to generate the images as needed. These images are color gradients where the start/stop of the gradient is based on the slider's thumb position (as well as other user-defined variables). Because there are many different images that could possibly be created, I am looking into generating the images at runtime rather than have hundreds of images stored somewhere.
    I am trying to generate these images using a BufferedImage that I can then write to a file. The path I am saving it at is as follows:
    FacesContext fc = FacesContext.getCurrentInstance();
    ServletContext sc = (ServletContext)fc.getExternalContext().getContext();
    String path = sc.getRealPath("/") + filename;
    I then create the file at the path and use ImageIO to write it:
    File f = new File(path);
    ImageIO.write(bi, "png", f);
    I am saving this file path in a variable in my backing bean that I then use on my ADF page to populate the background image field of the slider.
    Problem: when I run the page, my slider does not have a background image.
    Looking at the location where the file should be saved, it is actually "saving" it within a .war file which I don't think is appropriate (or possible, for that matter). Is there some way that I can save it either on the server side or the client side so that the client can see the background actually being updated using the generated image? I am almost positive that the path I listed above is incorrect - if this is the correct approach for this problem, where would be an appropriate location?
    Any pointers would be greatly appreciated. Thanks in advance for your help!

    Instead of saving the image to a file, why not use a Servlet to write the image to the Servlet's response stream. Then, you just point the background image to the Servlet.
    John

  • Using PHP to display semi-random images?

    Hello,
    I'm looking for help using PHP and MySQL to generate semi-random images on my web site. Here's what I'm trying to do: I have 60 images, but I only want to display 16 at a time (for examlpe http://artisdead.net/antelopegardens.php).
    The way I imagine this is, the design has 16 image placeholders. I want Placeholder 1 (the first image) to randomally pull record ID 1, 2, or 3 from the SQL database, while Placeholder 2 pulls record ID 4-6, etc. It's important that one of the first 3 images displays first, while one of the second 3 images displays next, etc.
    I've found various ways to randomize all the images, but I'm not understanding how to constrain the randomization the way I'm looking to. Any help would be greatly appreciated. Thanks in advance.

    Alamo_Melt wrote:
     The way I imagine this is, the design has 16 image placeholders. I want Placeholder 1 (the first image) to randomally pull record ID 1, 2, or 3 from the SQL database, while Placeholder 2 pulls record ID 4-6, etc. It's important that one of the first 3 images displays first, while one of the second 3 images displays next, etc.
    Before offering a possible solution, I should point out that your plan has a minor flaw. If you display only 16 images, and want the random choice to come from incremental sets of three, the maximum number you can have in your set is 48. The final 12 images will never be selected. For 60 images, you need 20 placeholders. The alternative is to have a total set of 64 images, and make the random choice come from incremental sets of four images.
    With that caveat, here's how I would do it. The primary keys of your records might not be consecutive, particularly if records are deleted and new ones added, so it might be a good idea to have a separate column with consecutive numbers from 1 to the the maximum. To select random numbers from incremental groups of three, use the following:
    $id = array();
    $min = 1;
    $max = 3;
    for ($i = 0; $i < 16; $i++) {
      // generate random number from current set
      $id[$i] = mt_rand($min, $max);
      // increment the minimum and maximum numbers for the next set
      $min += 3;
      $max += 3;
    // join the selected values as a comma-separated string
    $vals = implode(',', $id);
    $sql = "SELECT image FROM images WHERE id IN ($vals)";
    // excecute the SQL query

  • Image generator w/ customizable text, colors, etc?

    Hello,
    I was just wondering if there was some sort of module or
    application for ColdFusion that would allow me to generate images
    based on a user's input of text, colors, etc. Something like at
    http://www.finestationery.com...
    http://www.finestationery.com/prod_enter_wording.cfm?prod_id=27502&fss_id=1805200717151002 31481532356810&smain_id=47757042&cm_thiscategory=667&CFID=115729&CFTOKEN=92434145
    ... where the user can type text, set a font, change colors,
    etc, and hit "Preview" to view a generated JPEG with all of their
    personalized options.
    Is something like this available somewhere? Or does Fine
    Stationery just have a bunch of really studly programmers?
    Thanks!

    check out imagemagick (google it 'cos i don't remember the
    url) and
    imagecfc (www.opensourcecf.com/imagecfc/)
    both a free.
    Azadi Saryev
    Sabai-dee.com
    Vientiane, Laos
    http://www.sabai-dee.com

  • How to display image in database using php

    i've try search all hope that you all can give me some guidance how to display data that is in image or BLOB using PHP. just a query and php code that will make display of the image. hope that you all show me the example or give me reference that i need to solve my problem.

    Hi,
    Have a check on these Google results, you might find something there...
    http://www.google.com/search?sourceid=navclient-ff&ie=UTF-8&q=%22display%20image%22%2Boracle%20%2Bphp

  • How can I use IMGPLOT to display a 12-bit image in false color?

    I want to use IMGPLOT to display a 12-bit image in false color employing VC++ 7.0 . Actually it is stilla grey level. The only difference is to customize a new palette. I guess Ni should have a API for me change the palette. I donot want to convert my image into color image since its processing speed is slow.
    Any people has the silimar experience to do this?
    Thanks a lot in advance!
    zmt

    Hi Bruce Ammons,
    Thank you very much for your answer. I still need your clear instruction.
    I can directly display 12 bit image in 256 grey level just using IMGPLOT function without any mapping operation. That is because IMGPLOT directly supports to draw a 12 bit image through IMGPLOT_MONO_12 flag.
    IMGPLOT prototype is imgPlot(GUIHNDL window, void* buffer, uInt32 leftBufOffset, uInt32 topBufOffset, uInt32 xsize, uInt32 ysize, uInt32 xpos, uInt32 ypos, uInt32 flags=IMGPLOT_MONO_12 ).
    Hence I just need a C++ function to change the palette. I believe that IMGPLOT automatically does the 12bit to 8 bit mapping for me. What I need to do is just to change the palette. The question is which NI'S API can change the palette and work well with IMGPLOT. Or I have
    to use IMGPLOTDC and change the palette in the selected DC by myself.
    Your great help is much appreicated!
    zmt

  • Best way to update images using PHP / MySQL?

    HI
    I want to update images using PHP/MySQL, so users can update their images and maybe some other files but mainly images.
    thanks

    How messed up is this code?!
    <?php
    //connect to database
    $con = mysql_connect("testhost","testuser","pass");
    // file properies
    $file = $_FILES['image']['tmp_name'];
    if (!isset($file))
    echo "please select an image";
    else {
        $id = $_REQUEST['id_display'];
        $image = ($_FILES['image']['tmp_name']) ? file_get_contents ($_FILES['image']['tmp_name']) : '';
        $image_name = ($_FILES['image']['name']) ? addslashes($_FILES['image']['name']): '';
        $image_size = ($_FILES['image']['tmp_name']) ? getimagesize($_FILES['image']['tmp_name']): '';
        if ($image_size == FALSE)
        echo "You have not selected an image.";
        else {
            mysql_select_db("test_display", $con);
            mysql_query("UPDATE testtable SET image = '$image', imagename = '$image_name' WHERE id_display='$id'");
    ?>
    And the upload page....
    /*Update code */ /*End update code */                            

  • Is it possible to extract the text and images using PHP

    Hi friends,
    Is it possible to extract the text and images using PHP, in the same order as it is in the PDF?
    Else is it possible extract the same as XML using PHP, or ASP
    I googled it but its in vain, any help is appreciated.
    Thanks in advance.

    Dear Mike,
    Thanks for your quick reply,
    I mean is it possible to parse the PDF line by line using the PHP.
    I extracted the whole text but couldn't the images. Since the PDF's images are decoded using various methods like DCTDecode, JPXDecode, etc.
    The text is decoded with FlateDecode, which i breaked using a function in PHP.
    Thanks,

  • When printing to the dye sublimation epson stylus pro 7700 using adobe illustrator it is required that I mirror the image.  When mirroring the image the print colors are muted.  Not mirrored and the print colors are perfect.  Any suggestions?

    When printing to the dye sublimation epson stylus pro 7700 using adobe illustrator it is required that I mirror the image.  When mirroring the image the print colors are muted.  Not mirrored and the print colors are perfect.  Any suggestions?

    CS5
    On Tue, Oct 7, 2014 at 9:49 AM, ADBEDesigner <[email protected]>

  • Preloading images using PHP

    Hi,
    I am trying to pre-load a few images on a page to save the loading time but seems to be not working in IE7. Here is my code:
    <SCRIPT LANGUAGE="JavaScript">
    top1 = new Image();
    top1.src = "./1.jpg";
    top1 = new Image();
    top1.src = "./2.jpg";
    </script>
    This is declared in the HEAD section. But onmouseover still takes a second or two, but once loaded, mouseover is instant. I have an image name called top1, is it because i am loading the same object with 2 different images so will the first image not finish loading?
    Also, if I was to include filenames which are dynamic, is there anything stopping me from using PHP code in the HEAD section? or is there a better way to do this?
    Thanks in advance.

    What you are trying to do has very little to do with PHP, except the generation of the image names in the JavaScript. Once the web page is sent from the server, everything relies on JavaScript. I have created a simple demo on my website at http://foundationphp.com/test/preload.html.
    The following script in the head of the page preloads the image:
    <script type="text/javascript">
    (new Image()).src = "/images/9781430210115.jpg";
    </script>
    In the body of the page, the rollover is created like this:
    <p><img src="/images/9781430216100.jpg" width="130" height="160" alt="Book cover"
    onmouseover="this.src='/images/9781430210115.jpg'"
    onmouseout="this.src='/images/9781430216100.jpg'" /></p>
    Note that the <img> tag has the original image assigned to its src attribute, and the replacement images are specified in the onmouseover and onmouseout event handlers. You cannot do it simply by assigning the preload image to a variable in the head and then assigning that variable name to the image, because the image tag has not been created at the time the script runs.
    It sounds to me as though you want to rotate the images. If so, Google "JavaScript image rotator". You should find plenty of solutions.

  • Instruction on how to work with images and videos in the storage azure using php

    Dear Sirs
    I followed below instruction to make video and image storage on Azure using PHP:
    http://azure.microsoft.com/en-us/documentation/articles/storage-php-how-to-use-blobs/
    Whenever I record an image on Azure storage and download stored image there is no format
    in the stored image. and end up becoming like any other regular file. Othe problem is that I cannot see the concerned image in the browser. I already have checked recipient access and it is defined as public reading. 
    Could you also please provide me with an article instructing how to make upload,  download,
    show up on the browser and remove video and images from the azure storage area?
    Thanks & Regards,
    Pedro

    Hi Pedro,
    Thanks for your posting!
    I am not familiar with PHP. But from your description, I think your need pay attention to those points in your code:
    1.When you store file or download file, please write the file name and
    suffix, for example, you need store image as blob name "image.png".
    2.When you download file from Azure blob, you need set the content type.
    if your file is image, you could set the content type as image type.
    3.You could get the blob URI, and set your image URL as blob URI. Do this, you can show the picture.
    Please see this similar issue thread:
    http://phpazure.codeplex.com/discussions/472840
    Regards,
    Will
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • J2me send image using php as server

    hii all,can you help me give me a souce code for send image in j2me to server(i'm using php)????????? cause i need for my final projects
    thanks

    The reason i want to use gmail because i can't use smtp university's mail server( looking to the apple server error log is say something about IsSMTP(); function. today, i had discussion with them(ICT dept) and they can't solve it as there's no apple server used before/now and no one familiar with it. they give me other alternative by using a "secret server", a subdomain name were given with no smtp authentication. no username or password were used, not even using any ssl or tsl security. they give me this last solution when i install joomla on the other windows server and try to use university smtp server with email account. error saying cannot connect to smtp server. i did try also using joomla on my apple server still with the error. so what i understand now is that its related to university global networking security/policy setting(correct me if i'm wrong). so for the SL server, its should be super easy to setup if you are yourself configuring the internet direct to your ISP. thanks very much to Camelt for quick answered. So i should not facing any problem with apple server if i bought and connect it direct to my ISP, right Camelot?

Maybe you are looking for

  • Can't import class into JSP

    Hi, I am trying to import a class into my JSP and am getting the following error at runtime: org.apache.jasper.JasperException: Unable to compile class for JSP An error occurred at line: -1 in the jsp file: null Generated servlet error: [javac] Compi

  • How to export XI messages to XML files?

    Is there any way to download/export a message from XI?. I am thinking on the lines click and "Save As" for example, a message that just arrived from R/3 via RFC but before it gets further processing. I know that you can examine the message in XI but

  • Can QT 7 pro isolate audio from combined audio/video tracks?

    I just upgraded to Pro to try to convert small video clips (.mov files) taken on an HP digital camera into an iMovie-compatible format- they will play fine in QT (both audio and video), but there is no separate audio track. No matter what format I sa

  • Flatfile Issue

    Hello, I am uploading CSV file into BI Application server using WINSCP basically  this tool  FTP the CSV file into BI Application server. I am trying to load the data into PSA , I am getting below error message "Cannot convert character sets for one

  • ORACLE MATRIX CHANGE ALTERNATE COLUMN COLOR

    i have a Matrix Report and i wanted to change the alternate column color like GRAY | GREEN | GRAY | GREEN