gd

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

ぐ巨炮叔叔 提交于 2019-12-05 13:01:35
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? $curl = curl_init("http://minecraft.net/skin/Notch.png"); // Moved? Fear not, we'll chase it! curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); // Because you want the result as a string curl_setopt($curl, CURLOPT

how to detect blobs and crop them into png files?

断了今生、忘了曾经 提交于 2019-12-05 12:35:50
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 software written in python or c#. but i dunno what this operation called so i dunno what to google to

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

巧了我就是萌 提交于 2019-12-05 12:18:12
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 opening it, so I can avoid fatal errors? According to several sources the memory needed is up to 5 bytes

Resizing and cropping image with GD while retaining aspect ratio

与世无争的帅哥 提交于 2019-12-05 11:43:53
I'm currently coding an uploader script based on Uploadify. Right now I resize the given image and watermark one of the sizes. It all works well, but I need the script to resize the height and then crop the width so that the aspect ratio does not get messed up. This is my code so far: if ($fileExtension == "jpg" || $fileExtension == "jpeg" || $fileExtension == "png" || $fileExtension == "gif"){ // GD variables: list($width, $height, $type) = GetImageSize($uploadedFile['tmp_name']); // Image sizes: $bigImage = array(800, 453); $mediumImage = array(410, 231); $listImage = array(120, 68);

In PHP, imagepng() accepts a filter parameter. How do these filters affect the function's output?

為{幸葍}努か 提交于 2019-12-05 11:39:38
问题 How do these filters affect the output of imagepng() in PHP? PNG_NO_FILTER PNG_FILTER_NONE PNG_FILTER_SUB PNG_FILTER_UP PNG_FILTER_AVG PNG_FILTER_PAETH PNG_ALL_FILTERS The documentation simply says, "A special PNG filter, used by the imagepng() function" for each of them. It seems that using PNG_NO_FILTER will reduce the filesize of the output, but other than that, I am unsure as to how it is affected. Any insight would be really appreciated. 回答1: According to the PNG Specifications at http:/

CPAN GD module install failure using Cygwin

北城以北 提交于 2019-12-05 09:02:59
I have been trying to troubleshoot why CPAN GD module fails to install using Cygwin for 2 days now. Any help is much appreciated. Thanks! cpan install GD Going to read '/home/xxxxxxxxxx/.cpan/Metadata' Database was generated on Sat, 27 Dec 2014 12:17:02 GMT Running install for module 'GD' Running make for L/LD/LDS/GD-2.56.tar.gz Checksum for /home/xxxxxxxxxx/.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.1.0. Checking for stray libgd header files... ** WARNING: found gd.h header file in /usr/include/gd.h, but

PHP GD - Transparent areas goes black

独自空忆成欢 提交于 2019-12-05 08:05:47
I am trying to make very simple ISO engine in PHP, my attempts to render in correct place, order etc are succeding however the images drawn, for some reason are black where it should be transparent. PNG files have transparency channel and I am using following test code: http://pastebin.com/TXk4LkJ8 The code is just rough draft. Files are just 3 faces of an block with dimensions as follows: top - 44x22; sides:23x34 Thank you for your help and I hope the question is clear enough. Edit: Here is the problem: http://dl.dropbox.com/u/10530011/obrazki/isofail.png Edit: [ SOLVED ] For some reason I

Laravel 5.6: Create image thumbnails

依然范特西╮ 提交于 2019-12-05 07:24:57
In my old PHP apps i used to run a function like the one bellow to create jpeg image thumbnails. function imageThumbanail() { $image_src = imagecreatefromjpeg('http://examplesite.com/images/sample-image.jpg'); $thumbnail_width = 180; //Desirable thumbnail width size 180px $image_width = imagesx($image_src); //Original image width size -> 1080px $image_height = imagesy($image_src); //Original image height size -> 1080px $thumbnail_height = floor( $image_height * ( $thumb_width / $image_width ) ); //Calculate the right thumbnail height depends on given thumbnail width $virtual_image =

Create Image from Data URL

回眸只為那壹抹淺笑 提交于 2019-12-05 07:15:54
问题 What I was hoping to do was use the JavaScript "readAsDataURL" method of the "FileReader" object in order to read file input from a drag and drop. Then I wanted to use Ajax with a PHP upload file in order to create a file and upload it to an "uploads" folder on the server. I was wondering if there was a function in GD or something that would allow me to read in a data URL and output a file in which I could move to that folder. 回答1: A data image URL will usually be base64 encoded, and will

Take a thumbnail from a quicktime (movie) file

柔情痞子 提交于 2019-12-05 05:13:47
Does someone know if it's even possible (in PHP) to take a frame/thumbnail from a quicktime movie on the server? Something like the usual GD thumbnail generation, but for .mov files. note: I'm using dreamhost, so I don't have more than web-panel access to the server. Dreamhost provides a shared ffmpeg binary in /usr/bin/ffmpeg, so you should definitely be able to call ffmpeg from php by using the system() or shell_exec() functions. The Dreamhost wiki has also an entry providing directions on how to install and configure ffmpeg-php.. This looks promising: http://ffmpeg-php.sourceforge.net/index