gd

How to find shapes on image

拜拜、爱过 提交于 2019-12-08 13:00:12
问题 This is not related to any language atm, only math algorithm required. I have some image, lets say this one I need to cut tree from this image, sky with clouds and grass should be threated as background. Thanks for any help. 回答1: Probably the algorithm that your looking for is "blob detection". Here's a video example. Blob detection is implemented, for example, in OpenCV. In general, though, as several people have pointed out in the comments, what one means by "object" needs to be defined by

php - set alpha of each pixel in image

此生再无相见时 提交于 2019-12-08 10:49:11
问题 I want to set the alpha of each pixel in image using php gd functions. So far i have this: $src = imagecreatefrompng('image.png'); $w = imagesx($src); $h = imagesy($src); $alpha = 204; for ($x = 0; $x < $w; $x++) { for ($y = 0; $y < $h; $y++) { // set $alpha for each pixel in $src } } imagepng($src); imagedestroy($src); 回答1: Alpha have to be defined into 0 and 127. Then you have to use imagealphablending() and imagesavealpha() to save and use alpha. $src = imagecreatefrompng('image.png');

Lightbox displays garbage characters instead of image

家住魔仙堡 提交于 2019-12-08 08:18:01
问题 I have installed a lightbox script in my website. When lightbox pops up, but there are garbage characters displaying instead of the large version of the image: ����JFIF��;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 90 ��C ��C ����"�� ���}!1AQa"q2���#B��R��$3br� %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz������������������� What is this? It looks like it's relevant to the image file but I don't understand what causes this issue... Any suggestions? Edit: Here's the whole code of the

GD/imagick code to find if an image is well-focussed or not?

不想你离开。 提交于 2019-12-08 06:01:11
问题 I run a website with thousands of user-contributed photos on it. What I'd like is a script to help me weed out poor photos from good photos. Obviously this isn't 100% possible, but it should be possible to determine if an image has no discernable focussed area? I think? I did a bit of googling and couldn't find much on the subject. I've written a very simple script that iterates over the pixels, and sums the difference in brightness between neighbouring pixels. This gives a high value for

How to detect a partial vertical/horizontal line in a image?

放肆的年华 提交于 2019-12-08 05:28:03
问题 I have an image and I have a partial line in the image. They are all the time horizontal or vertical lines. I don't know the color of the line, neither the width of the line. How can I use PHP to detect such a line? As you see in the uploaded image, there are 3x3 sections I need to slice. I need the 3 vertical, and 3 horizantal sections to slice the parts. Please note there is a rectangle with some markes around the content area, that is part of the images. We can use those markers to get the

Why does my Image stretch when I crop it?

萝らか妹 提交于 2019-12-08 04:39:08
问题 I am using the following code snippet in order to crop a image? function crop($width,$height) { $new_image = imagecreatetruecolor($width, $height); imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $this->getWidth(), $this->getHeight(), $width, $height ); $this->image = $new_image; } Here, $this->image is the original image $this->getWidth() and $this->getHeight() holds the original dimensions of the picture, where as $width and $height , is the crop area. But for some reason, the crop

PHP: Add a Transparent PNG to a JPEG with Opacity

风流意气都作罢 提交于 2019-12-08 03:06:17
问题 This seems to be a common question, but trying all the combinations, I have found, it still is not working for me. My PNG watermark is transparent and I wish to overlay the original JPG with this watermark and add a 50% opacity to the watermark. The watermark is added and the opacity created, but the transparency of the PNG is rendered as opaque white. I have seen examples using imagecopy() but that function does not have the option to add opacity. My code is as follows: <?php $file = 'orgCar

Mystery issue with GIF upload?

隐身守侯 提交于 2019-12-08 03:04:11
问题 Alright, so whenever I upload this GIF to my board (NGINX+PHP-FPM) I get a slow down until an eventual 504 Gateway Time-out, alright, so I know what you're thinking, "go ahead and fix those nginx.conf and php-fpm settings", well I tweaked them to near perfection last night, my server is running brilliantly now. However, that one particular GIF still screws up, runs php-FPM to almost 100% (I have a great top of the line quad core processor in my server, my server is by no means primitive). So

PHP-GD imagejpeg unable to open

倖福魔咒の 提交于 2019-12-08 01:35:49
问题 When trying to save a thumbnail made with GD imagejpeg($tnImage, "../../img/thumbs/".$maxWidth."x".$maxHeight."_".$filename); I am getting the following error: Warning : imagejpeg() [function.imagejpeg]: Unable to open '../../img/thumbs/80x80_55865-drops.jpg' for writing: No such file or directory in /home/user/workspace/stewart/server-side/libImg.php /home/user/workspace/img/thumbs has its permissions set to 0x777. What can be wrong here? 回答1: Where are you running the file from? If it's

Blend transparent gradient with an image using php GD library

自古美人都是妖i 提交于 2019-12-07 21:12:56
问题 I try to render gradient on top of an image it need to be from full color to transparent, here is my code. I get black image and if I put start more then 0 I got white gradient but no image. the output image is 338x100 px but the input image need to be aligned to right if the image is narrower. function hex2rgb($hex) { $rgb[0] = hexdec(substr($hex, 0, 2)); $rgb[1] = hexdec(substr($hex, 2, 2)); $rgb[2] = hexdec(substr($hex, 4, 2)); return $rgb; } function int2rgb($color) { $result[] = ($color