SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot malluwood's Avatar
    Join Date
    Nov 2006
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Creating circle image in php

    hi all

    I am uploading a normal image to server and storing path in database.Now,My question here, I want to create a round image in php. that is ,I want to convert this normal picture to round(wheel type or circle) image dynamically .How can i do this in php? is it possible to do in GD.How can i convert normal(square) picture to circle image dynamically from the server

    please help me?

    Thanks & Regards to all

  2. #2
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,397
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    I think your picture will always be square; all you can do is overlay a mask or something to make it seem round.
    PHP Code:
    <?php
    // Create the mask - in this case a circle but could be any shape, make sure the mask is large enough to cover the whole image
    exec("/usr/local/bin/convert -size 200x200 xc:none -fill blue -draw 'circle 100,100 100,13' circle.png");
    // Use the mask to remove everything apart from the circle move the mask where you want with -geometry +0+0
    exec("/usr/local/bin/composite -compose Dst_Out circle.png -geometry +0+0 image.jpg -matte new_image.png");
    unlink("circle.png");
    ?>
    Imagemagick method, from memory the background should be transparent; may need to make it a gif instead of png but you will get a colour if you save as jpg. I would guess if you want to save as a jpg you would need to change xc:none to your page background colour.

  3. #3
    SitePoint Zealot malluwood's Avatar
    Join Date
    Nov 2006
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry

    Thanks,I am uploading square images,then i want to convert.but uploading both gif and jpeg.

    I haven't used image magic.is it free ?can i use commercially?

    is it possible to create the circle without using image magic ?

    Thanks

  4. #4
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,397
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    God knows what I have done but the PC has gone mad doing things I do not want it to do !

    I hit the Ctrl key and another one and now can get out of whatever is happening.

  5. #5
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,397
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    Imagemagick is free but depends if your host has it installed; it can deal with most image formats without setting different codes for different types. The other major image manipulating software is GD library; which I do not know so much about.

    Put this code onto a page and run on your server to see if you have ImageMagick installed:
    PHP Code:
    <?php 
      header
    ("Content-Type: text/plain"); 
      
    system("exec 2>&1; type convert");
    // Output: convert is /usr/local/bin/convert   
      
    system("exec 2>&1; convert -version"); 
    // Output: Version: ImageMagick 6.2.8 06/10/06 Q16 http://www.imagemagick.org
    // Copyright: Copyright (C) 1999-2006 ImageMagick Studio LLC  
    ?>
    It should display the info but may ask you to download a file which will contain the info.
    A round image created with a different ImageMagick method -
    http://www.rubblewebs.co.uk/imagemagick/other.php


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •