Is it possible to make a transparent png image with php that has custom shape? For example, I've got a jpg image at server. Using php imagemagik or GD2 I would like to save it as transparent png and the transparency is custom shape. I hope it's clear. If it's not I will send an example.
Regards,
Dave
Umm it is possible to make it transparent, basically you can set a color as transparent, and the library will make each matching pixel transparent. I'm not sure what you mean by the shape though.
http://php.net/manual/en/function.imagecolortransparent.php
Related
I need to manipulate images on the server-side via PHP. I use ImageMagick for that purpose, and there are a lot of great functions, but no documentation...
The issue is the next:
I have two images a png with a transparent background, and a jpg one;
I need to change the JPG image that has the same shape as the visible part of the PNG.
I don't want to crop the image, but to adjust to the PNG's visible part. Is that possible to do?
Example:
I need to convert all non transparent pixels to one color (e.g. black).
I can only use the methods exposed by the php imagick extension http://php.net/manual/en/class.imagick.php
as exec() is blocked on the server.
what would be the quickest route to achieve this?
In the end I created a black pseudo image and copied the opacity from the original image to the new pseudo image
I have a default image that I want my users when they first create their profile to have, and I need to each one of them have a different background color but with the same base shape that will be in a png file, I can do this by creating for each background color create a png but I dont think it might be the best choice. How can I do this?
Use Imagick extension to work on your image. You can set a background color for your transparent png image by simply doing this
shell_exec("convert testimage.png -fill '#CCCCCC00' -opaque none image_wth_bgcolor.png");
This will give a slight gray(#CCCCCC) background to the the image.
See this link.
My suggestion is to create a png file for each colour (which seems to be the only way)
and use PHP to randomly pick one of the images.
I'm working on a script for which I need to do the following:
User uploads an image (JPG, PNG, GIF). PHP resizes it, increases the canvas size, and saves the images as a PNG file on the server.
Now I found this tutorial to learn how to do that:
http://www.webxpert.ro/andrei/2009/01/08/thumbnail-generation-with-php-tutorial/
However, this will create a PNG file with a white background. Is it possible to have PHP generate it with a transparent background?
Thanks!
The tutorial breaks it down into basic steps. Just find the step that puts a background colour in there, and put a transparent colour instead. You will need imagecolorallocatealpha and an alpha value of 127.
I'am using PHP GD to copy an image (watermark) on another image.
Unfortunately the quality of the watermark is terrible.
I'm using quality 100% as the attribute, but it doesn't help.
Have you guys know any good way to increase the quality?
Regards.
A 90% quality should give you the exact same results and decrease the file size by half (on JPEG, OFC).
Try using ImageCopyResampled() instead of ImageCopyResize(), other than that I don't think you can do anything else with GD alone, maybe Imagick has some other tricks.
Are you using any transparency, or is it just a solid square. What exactly looks bad about the quality? The edges, the whole thing?
I like to use a 24bit transparent PNG for the watermark, and imagemagick to do the overlay, you get a lot of control over the final product that way.
Lots of possibilities for watermark with imagemagick:
http://www.imagemagick.org/Usage/annotating/