gd

Embedding IPTC image data with PHP GD

允我心安 提交于 2019-12-07 18:33:43
问题 I'm trying to embed a IPTC data onto a JPEG image using iptcembed() but am having a bit of trouble. I have verified it is in the end product: // Embed the IPTC data $content = iptcembed($data, $path); // Verify IPTC data is in the end image $iptc = iptcparse($content); var_dump($iptc); Which returns the tags entered. However when I save and reload the image the tags are non existant: // Save the edited image $im = imagecreatefromstring($content); imagejpeg($im, 'phplogo-edited.jpg');

Drawing on image with the GD library in PHP

一笑奈何 提交于 2019-12-07 17:54:16
问题 I have created a code to generate a random pattern image. it creates an image with given width and height and fills it with small 40x40 pixel rectangles. this is my code: <?php $width = 1000; $height = 600; $image_p = imagecreate($width, $height); $baseR = 255 - rand(0, 100); $baseG = 255 - rand(0, 100); $baseB = 255 - rand(0, 100); for ($i = 0; $i <= floor($width / 40); $i++){ for ($j = 0; $j <= floor($height / 40); $j++){ $val = floor(100 * (rand(0, 100) / 100)); $r = $baseR - $val; $g =

Compress & save base64 image

守給你的承諾、 提交于 2019-12-07 14:13:27
问题 My app is receiving base64-encoded image-files from the webbrowser. I need to save them on the client. So I did: $data = base64_decode($base64img); $fileName = uniqid() . '.jpg'; file_put_contents($uploadPath . $fileName, $data); return $fileName; Which works fine. Now I need to compress & resize the image to max. 800 width & height, maintaining the aspect-ratio. So I tried: $data = base64_decode($base64img); $fileName = uniqid() . '.jpg'; file_put_contents($uploadPath . $fileName, $data);

Way to find an image inside another image in PHP/GD?

北城以北 提交于 2019-12-07 12:23:01
问题 I need a way to find the location of an image inside another image in PHP/gd. For example, locate this image: inside this image: I tried to make a function myself to do this, and I WAS successful, but it's very slow, it takes over 50 seconds at 100% CPU for me with the example pictures above, and I'm not sure how to optimize it (if possible) further. So is there some way to do this faster? Preferably, much faster? (For instance Auto Hotkey can do the same operation in <2 seconds on the same

PHP update kerning problem with imagettftext() and imagefttext() functions

走远了吗. 提交于 2019-12-07 11:07:23
问题 Our dev server was recently upgraded to PHP v5.2.13. With that upgrade we have found that our png images are having kerning (letter spacing) problems. We've tried numerous fonts and haven't found a solution yet. We are creating images using the GD library and writing text to the images using font files and the imagettftext() or imagefttext() functions. Has anyone else run into this? Am I misunderstanding something or should this be submitted to PHP as a bug? Are there any cool workarounds I

How can I check if a jpeg will fit in memory?

廉价感情. 提交于 2019-12-07 10:39:18
问题 Opening a JPEG image using imagecreatefromjpeg can easily lead to fatal errors, because the memory needed exeeds the memory_limit . A .jpg file that is less than 100Kb in size can easily exceed 2000x2000 pixels - which will take about 20-25MB of memory when opened. "The same" 2000x2000px image may take up 5MB on the disk using a different compression level. So I obviously cannot use the filesize to determine if it can be opened safely. How can I determine if a file will fit in memory before

how to detect blobs and crop them into png files?

喜夏-厌秋 提交于 2019-12-07 09:42:52
问题 i've been working on a webapp. i got stuck here in a problematic issue. i'll try to explain what im trying to do. here you see first big image which has green shapes in it. what i want to do is to crop those shapes into different png files and make their background transparent like the example cropped images below the big one. The first image will be uploaded by user and i want to crop into pieces like the example cropped images above.it can be done with GD library of php or by a server-side

How can get an image from a 301 redirect download link in PHP?

╄→尐↘猪︶ㄣ 提交于 2019-12-07 08:42:20
问题 I'm trying to download this image with PHP to edit it with GD. I found many solutions for image links, but this one is a download link. Edit: $curl = curl_init("http://minecraft.net/skin/Notch.png"); $bin = curl_exec($curl); curl_close($curl); $img = @imagecreatefromstring($bin); This is my current code. It displays "301 Moved Permanently". Are there CURLOPTs I have to set? 回答1: $curl = curl_init("http://minecraft.net/skin/Notch.png"); // Moved? Fear not, we'll chase it! curl_setopt($curl,

PHP - Mask polygon over image

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 07:31:03
问题 Hi Everyone (this is my first post), I am trying to figure a way of cropping a polygon out of an image. I have been reading other similar code. It seems that most code is based around the following process: Resize the image to fit the width and height of the polygon shape, Create a blank image of an unusual colour the same size, Overlay transparent pixels in the shape of the polygon, Overlay that on to the resized image Set the unusual colour to be transparent... My problem is I do not want

sIFR or FLIR?

拟墨画扇 提交于 2019-12-07 07:15:25
问题 I've recently bumped into facelift, an alternative to sIFR and I was wondering if those who have experience with both sIFR and FLIR could shed some light on their experience with FLIR. For those of you who've not yet read about how FLIR does it, FLIR works by taking the text from targeted elements using JavaScript to then make calls to a PHP app that uses PHP's GD to render and return transparent PNG images that get placed as background for the said element, where the overflow is then set to