SitePoint Sponsor

User Tag List

Results 1 to 20 of 20
  1. #1
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Changing & Saving an image with php

    Hi,
    I have a link to an image froma adifferent website, say, http://www.abc.com/images/logo.gif

    Now, i have that link, and i wana do the following ::

    1) Change the background color of image
    2) Save that file on, say, my server or computer

    its urgent. can anyone help me please
    ---------------------------
    Errors = Improved Programming.
    My Site

  2. #2
    SitePoint Wizard Young Twig's Avatar
    Join Date
    Dec 2003
    Location
    Albany, New York
    Posts
    1,355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, you'd have to define what the dimentions of the background are.

  4. #4
    Non-Member
    Join Date
    May 2005
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use the force, young padawan

  5. #5
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, i got the part on how to save the images. which i can simply use fopen and then create the file by reading the image file with file_get_contetns(which i wasn't aware that i could do this, till now)

    But, now, when i get the image, i have to change the background and then save it. this part is what i am not sure of.

    say, i have image with white background and i wana change it to gray.

    and also change image size from whatever to 100*133

    can you help please?
    ---------------------------
    Errors = Improved Programming.
    My Site

  6. #6
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you know exactly where the background begins and ends?

  7. #7
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dylan B
    Do you know exactly where the background begins and ends?
    sorry, i am not sure what you mean.
    i just have an image, say, 100*133, and i just have to change its background. i don't have any other specifcs of this image.
    ---------------------------
    Errors = Improved Programming.
    My Site

  8. #8
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BTW, image is jpg, if it matters and i have PHP 4.3.12 on Apache 2.0.53 on Windows XP
    ---------------------------
    Errors = Improved Programming.
    My Site

  9. #9
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP isn't going to know what the foreground is, and what the background is.

    How do you expect it to only change the background?

  10. #10
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So, what do i need to do??
    here's the scenario:
    user enters a url of a remote page and then script goes to that page and gets all the images and turn their background to gray.

    IS this possible??
    EDIT: the background is white. if it was tranparent i could have used i tanywhere.
    ---------------------------
    Errors = Improved Programming.
    My Site

  11. #11
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, because PHP can't tell what is the foreground, and what is the background.

  12. #12
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there any other way around it??
    ---------------------------
    Errors = Improved Programming.
    My Site

  13. #13
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why do you need to do this?

  14. #14
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My client want to get a product images from other website and wana show in his directory. But, he want to change the image background to match his website's background.

    That's what the problem is.
    ---------------------------
    Errors = Improved Programming.
    My Site

  15. #15
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should check copyright laws about that. The images are probably copyright of the website you're taking them from.

    If the background is a solod color, you MIGHT be able to do it.

  16. #16
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I already told them about this and they are ready to go for this.

    What do you mean solid colr. can you please explain it??

    i really want to do it is possible

    the image is actually created with white background (show've been used transparent but..)

    so, you think there's still hope
    ---------------------------
    Errors = Improved Programming.
    My Site

  17. #17
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, I don't think it is possible.

  18. #18
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, well,
    was worth a try
    thanks
    still wonder if its possible, i would relaly like to see it

    thanks anyways
    ---------------------------
    Errors = Improved Programming.
    My Site

  19. #19
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might be able to break the graphic down pixel by pixel, check if it is white, and if it is, recolor, but that's beyond me.

  20. #20
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Dylan, i know i can do that in VB but don't know if that's possible in PHP,

    but thanks for your help
    ---------------------------
    Errors = Improved Programming.
    My Site


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
  •