gd

How can I detect / calculate if a small pictures is present inside a bigger picture?

隐身守侯 提交于 2019-11-29 00:07:19
What I am trying to accomplish in PHP with GD or ImageMagick is the following: I have one large image (say 2000 x 2000 pixels).. I would like to check if a second, smaller image (say 50 x 50 pixels) appears somewhere inside the larger picture, and to what percentage the area is a match.. So, for example, there's a 95% match of the smaller image at that place in the larger image.. Is this possible? How could this be achieved? Thanks!!!! I had a quick look in PHP's ImageMagick and GD and neither has a built in way of doing that. An approach could be to use ImageMagick to divide the larger image

How do I fill white background while resize image

▼魔方 西西 提交于 2019-11-28 23:46:40
Current background is black. How to change the color to be white? #assuming the mime type is correct switch ($imgtype) { case 'image/jpeg': $source = imagecreatefromjpeg($source_image); break; case 'image/gif': $source = imagecreatefromgif($source_image); break; case 'image/png': $source = imagecreatefrompng($source_image); break; default: die('Invalid image type.'); } #Figure out the dimensions of the image and the dimensions of the desired thumbnail $src_w = imagesx($source); $src_h = imagesy($source); #Do some math to figure out which way we'll need to crop the image #to get it proportional

imagepng() and transparency in GD library with PHP

落花浮王杯 提交于 2019-11-28 23:19:46
When using the function imagepng() in PHP, how can I make sure the images that I save are saved with a transparent background? Eric Here is an example of the imagecolortransparent function (if it helps): <?php // Create a 55x30 image $im = imagecreatetruecolor(55, 30); $red = imagecolorallocate($im, 255, 0, 0); $black = imagecolorallocate($im, 0, 0, 0); // Make the background transparent imagecolortransparent($im, $black); // Draw a red rectangle imagefilledrectangle($im, 4, 4, 50, 25, $red); // Save the image imagepng($im, './imagecolortransparent.png'); imagedestroy($im); ?> Simply do this:

How to replace black background with white when resizing/converting PNG images with transparent backgrounds to JPEG.

♀尐吖头ヾ 提交于 2019-11-28 23:14:42
I am using a script that lets users upload images. The script resizes and converts the images to JPEG. The problem I have is when a PNG with transparency is uploaded, the resulting JPEG image is black where there was transparency. How can I edit the below script to replace the black with white? It already does this for GIF's but not for PNG's. // RESIZE IMAGE AND PUT IN USER DIRECTORY switch($this->file_ext) { case "gif": $file = imagecreatetruecolor($width, $height); $new = imagecreatefromgif($this->file_tempname); $kek=imagecolorallocate($file, 255, 255, 255); imagefill($file,0,0,$kek);

Background image dark or light?

僤鯓⒐⒋嵵緔 提交于 2019-11-28 22:51:06
问题 I'm doing a ODP->HTML conversion with PHP. I have problems with the following: Use the style:use-window-font-color property to specify whether or not the window foreground color should be as used as the foreground color for a light background color and white for a dark background color. (OpenDocument specification version 1.0, 15.4.4) If i have a background image, how do i check, if this image is light or dark? Do you have any ideas? Thanks in advance, Levu 回答1: I thought this was quite an

Right align text in an image with imagettftext(), PHP

三世轮回 提交于 2019-11-28 22:28:33
问题 I am setting up dynamic forum signature images for my users and I want to be able to put their username on the image. I am able to do this just fine, but since usernames are different lengths and I want to right align the username, how can I go about doing this when I have to set x & y coordinates. $im = imagecreatefromjpeg("/path/to/base/image.jpg"); $text = "Username"; $font = "Font.ttf"; $black = imagecolorallocate($im, 0, 0, 0); imagettftext($im, 10, 0, 217, 15, $black, $font, $text);

Resize image before uploading PHP

人盡茶涼 提交于 2019-11-28 22:09:09
I have no idea how to resize image in PHP, my code is: for ($index = 1; $index <= 2; $index++) { if (!empty($_FILES["pic$index"]["name"])) { $ext = substr($_FILES["pic$index"]["name"], strrpos($_FILES["pic$index"]["name"], '.') + 1); $dir = "../gallery/$mkdir"; HERE I NEED THE RESIZE OF THE TMP FILE OF IMAGE move_uploaded_file($_FILES["pic$index"]["tmp_name"] , "$dir/img-$index.$ext"); } } $mkdir = the name of the gallery's folder (there are many galleries). $dir = where the pics will be placed. $ext = the type of the image (png, gif or jpg). foreach loop runs two times because you can upload

GD vs ImageMagick vs Gmagick for jpg? [closed]

匆匆过客 提交于 2019-11-28 14:47:46
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I am in the step to abandon GD for manipulating image in my website - it is awful. Everyone saying to use ImageMagick because they are

Perl GD module won't install -

会有一股神秘感。 提交于 2019-11-28 13:56:54
I'm trying to figure out why I can't get the GD perl module to install on my Debian 7 server. Here is how I installed the core stuff: sudo apt-get install libgd-gd2-perl Then running the -MCPAN to install, I get: root@myserver:~# sudo perl -MCPAN -e 'install GD' Going to read '/root/.cpan/Metadata' Database was generated on Sun, 19 Jul 2015 21:41:02 GMT Running install for module 'GD' Running make for L/LD/LDS/GD-2.56.tar.gz Checksum for /root/.cpan/sources/authors/id/L/LD/LDS/GD-2.56.tar.gz ok CPAN.pm: Going to build L/LD/LDS/GD-2.56.tar.gz Configuring for libgd version 2.0.36. Checking for

php imagettftext and specific emoji

徘徊边缘 提交于 2019-11-28 12:18:33
问题 I've run into a problem drawing emoji that are under the 'Miscellaneous Symbols And Pictographs' unicode block. Here is an example code: <?php header('Content-Type: image/png'); $im = imagecreatetruecolor(290, 60); $grey = imagecolorallocate($im, 200, 200, 200); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 289, 59, $grey); $font = 'seguisym.ttf'; $font = realpath($font); //🌀 is the unicode html entity for a cyclone. It is under 'Miscellaneous Symbols And