Would it be possible to detect the compression level of a JPEG image using PHP, without having the "original" (uncompressed) version of the file?
If yes, how to do it?
Yes PHP Imagick can do this for you.
http://www.php.net/manual/en/imagick.getcompression.php
http://www.php.net/manual/en/imagick.getcompressionquality.php
Related
Users of my PHP webapp are permitted to upload PNG and JPEG images. Upload algorithm is following:
check extension by file name parsing
check extension by getimagesize()
recreate image by imagecreatefrompng()/imagepng() (imagecreatefromjpeg()/imagejpeg())
rename image
save to filesystem
Image recreation is used for security. Everything works fine. But now i need this algorithm to handle .ico files. It seems like GD doesn't work with .ico (there is no function like imagecreatefromico()), so i don`t know how to implement step 3 of my algorithm.
Thanks for any help or advice.
See https://github.com/lordelph/icofileloader for a composer-installable class which can load .ico files into a GD image.
For example:
$loader = new Elphin\IcoFileLoader\IcoFileService;
$im = $loader->extractIcon('/path/to/icon.ico', 32, 32);
See documentation for other methods of analysing and extracting images from the icon file.
our website has a certification image created by PHP GD, and I can print and watch it on a web page. But I couldn't make it a downloadable PDF file. Is there a way I can do that?
You can first save the image somewhere and then use the FPDF lib to write it in a PDF file
you could use imagick to do this..
the below command does the trick if your server is properly configured - Imagick is installed, GhostScript is installed, php is allowed to execute shell commands, etc
shell_exec('convert /path/to/input.png /path/to/output.pdf')
Images in my website is located in other server. I tried to get the size of an image using getimagesize of php and it is not working. It gives an error 'getimagesize is not seekable'. I tried this same function from other server(images are in same server and I change the location of the file, which is using getimagesize function) and it worked. Can anyone solve this?
From the manual:
filename
This parameter specifies the file you wish to retrieve information about. It can reference a local file or (configuration permitting) a remote file using one of the supported streams.
The settings they're talking about (for the HTTP wrappers) is for the most part having allow_url_fopen enabled or disabled.
The error is probably could not make seekable and could mean that PHP / GD cannot recognize the image file as such.
Have you tried with different images and different image formats (GIF, JPG, PNG) ?
Maybe GIF or PNG is not supported by your PHP version.
maybe the image path is wrong
try using this instead:
dirname($_SERVER['SCRIPT_FILENAME'])
it will return the parent directory's path,
example:
getimagesize(dirname($_SERVER['SCRIPT_FILENAME']).'/images/sampleimage.jpg');
how to get SWF file dimensions in PHP?
getimagesize I believe accounts for swfs: http://us.php.net/getimagesize
You could install and run the swfdump utility.
I've also read that PHP's getimagesize() has some limited support for SWF files.
I'm using PHPs imagecreatefromjpeg to load a jpeg from disk and imagejpeg to output that image to the browser. For some reason though, this function is only outputting the image when the server is running on a Windows development box. On our Linux server, its not outputting any data (ie. Content-Length: 0, nothing is displayed).
Are there any workarounds that make this work on a Linux box? I've confirmed that the GD library is installed with jpeg support.
There are two notes on http://php.net/imagejpeg which may be relevant:
Notes
Note: JPEG support is only available
if PHP was compiled against GD-1.8 or
later.
Note: If you want to output
Progressive JPEGs, you need to set
interlacing on with imageinterlace().
Also some actual code would be useful in attempting to help.
Make sure you have the correct file permissions set. Does your web service own the file? Does it have permission to read or write the file?