Questions tagged [imagecreatefrompng]

Anything related to imagecreatefrompng PHP function for creating an image from file or URL

imagecreatefrompng is a PHP function that returns an image identifier representing the image obtained from file or URL

109 questions
23
votes
3 answers

Create a transparent png file using PHP

Currently I would like to create a transparent png with the lowest quality . The code:
user782104
  • 13,233
  • 55
  • 172
  • 312
14
votes
3 answers

Trying to extract pixel values from a given PNG image

Trying to understand PNG format. Consider this PNG Image: The Image is taken from here In Hex Editor , it looks like this: 89 50 4E 47 0D 0A 1A 0A 00 00 00 0D 49 48 44 52 00 00 00 80 00 00 00 44 08 02 00 00 00 C6 25 AA 3E 00 00 00 C2 49 44 41…
gpuguy
  • 4,607
  • 17
  • 67
  • 125
13
votes
3 answers

Can I use a URL as the source for imagecreatefromjpeg() without enabling fopen wrappers?

I know it’s possible to use imagecreatefromjpeg(), imagecreatefrompng(), etc. with a URL as the ‘filename’ with fopen(), but I'm unable to enable the wrappers due to security issues. Is there a way to pass a URL to imagecreatefromX() without…
iRector
  • 1,935
  • 4
  • 22
  • 30
8
votes
6 answers

PHP imagecopy with transparent background

I use this code to create an image from another png image, the background is black by default. My question is how to set a transparent background? $input = imagecreatefrompng('image.png'); $output = imagecreatetruecolor(50, 50); imagecopy($output,…
2by
  • 1,083
  • 5
  • 22
  • 39
4
votes
4 answers

How to allow upload transparent gif or png with php

I have this function below to allow me to resize my uploaded image, function resize_image($image,$width,$height,$scale) { list($imagewidth, $imageheight, $imageType) = getimagesize($image); $imageType = image_type_to_mime_type($imageType); …
Run
  • 54,938
  • 169
  • 450
  • 748
3
votes
2 answers

PHP imagecreate() PNG from any commonly used file-format?

I currently have an image upload input that only accepts PNG, JPG/JPEG, GIF images. If the file is valid, it then proceeds to create a thumbnail from the image using imagecreatefrompng() imagecopy() imagejpg() This works fine, but ONLY for png…
Aaron
  • 1,956
  • 5
  • 34
  • 56
3
votes
2 answers

imagecreatefrompng error - how to detect and handle?

In my script, I have the following lines: $test = @imagecreatefrompng($name); if ($test) { ... } I am certain that $name represents an existing file on the disk, but I must handle cases where that file is not a valid PNG file (either because of a…
Victor Nicollet
  • 24,361
  • 4
  • 58
  • 89
3
votes
2 answers

Can't Create QR With Text Below

I use this codes for making qr code with custom text below. I tried several methods but I always failed. I need to help. // Set the content-type header('Content-Type: image/png'); header("Content-Disposition: filename='sample.png'"); $main =…
eneskomur
  • 91
  • 1
  • 13
3
votes
2 answers

Crop a Square Image of 450x450 into 9 pieces of 150x150 each, using PHP

I have an source image of 450x450 px. And i want to crop it into 9 peices of 150x150 each using PHP. I am using the following code. I am getting 9 images, but cropping is not appropriate. Here is the screen shot : Last one is the source image i am…
jackkorbin
  • 491
  • 7
  • 22
3
votes
1 answer

imagecreatefrompng() from base64 code?

is there a way to create an image with imagecreatefrompng() with this base 64 PNG code in PHP?
Jordan Jones
  • 127
  • 1
  • 2
  • 8
3
votes
1 answer

PHP imagecreatefrompng losing color

I'm doing a simple load of an image using imagecreatefrompng. The background of the image is #E5DDBB. Using the code below, it renders the image but the background is now #DED6AD. http://www.letslogic.com/test.php contains the following:
3
votes
1 answer

Find White Pixel Lines

I want to replace all white pixel from a completely white column with other color and if I have a black pixel on column don't change anything, but I don't know where is the problem... Here is the code: function findLines() { $blank = 1; …
Alex F
  • 41
  • 3
2
votes
1 answer

PHP: Transparent background

$c = 'johnny-bravo.png'; //transparent bg $imagesize = getimagesize($c); $background = imagecreatefrompng('background.png'); //background $char = imagecreatefrompng($c); imagealphablending($char, false); imagesavealpha($char,…
2
votes
1 answer

Imagecreatefrompng() - Connection was reset error

I have installed a piece of code on a website, wich includes gd functions. After debugging I came to a conclusion that the $src = imagecreatefrompng($s); is causing the server to respond: "Connection was reset" Even if I change the code to: $src =…
Ernest Marcinko
  • 405
  • 3
  • 12
2
votes
1 answer

How to prevent having the "is not a valid image file" error when using GD function imagecreatefrom* in php?

I am using imagecreatefromgif / imagecreatefromjpeg / imagecreatefromjpeg functions with uploaded images and sometimes get an error (e.g. Warning: imagecreatefromgif(): ... is not a valid GIF file) when the image is corrupted. I read lots of posts…
user977191
  • 821
  • 2
  • 9
  • 11
1
2 3 4 5 6 7 8