I get poor image quality when trying to generate image using PHP GD. Here is the code http://paste2.org/p/1220178 I use it to convert a bunch of files into a merged/thumb images file.
Use imagecopyresampled() instead of imagecopyresized().
Related
I need to manipulate images on the server-side via PHP. I use ImageMagick for that purpose, and there are a lot of great functions, but no documentation...
The issue is the next:
I have two images a png with a transparent background, and a jpg one;
I need to change the JPG image that has the same shape as the visible part of the PNG.
I don't want to crop the image, but to adjust to the PNG's visible part. Is that possible to do?
Example:
I want to convert PDF pages to JPEG, but I want each page to be converted to 3 images.
First one is high quality
Second is mid quality
Third is thumb images
I use this code but I did not know how to make it to 3 images:
$im = new Imagick();
$im->setResolution(100,100);
$im->readImage("files/xx.pdf");
$im->setImageFormat('jpeg');
$im->writeImages("files/oman/oman.jpg",false);
This code will only convert each PDF page to one image.
Once you've created the first high res version of the page as a jpg, then just use php gd to resize it by reading in that generated jpg and resizing it down and exporting another jpg. This is the function you want and that page shows a simple example of how to resize images.
UPDATE: This shows a pretty simple tutorial on how to resize with php
UPDATE: Sorry, look at the php.net link above, there are many many examples of how to resize an image, here is a simple one. All you need to do is take what is returned and use imagepng() to save the file locally. (There are similar functions to save gif/jpg)
So far, I've been uploading one image by hand (FTP to the server when live, locally moving a file), and then resizing them on the fly using the img tag's width and height properties to resize them. Well, the images don't look good, because I need a square, cropped 100px version as a thumbnail, and then a 800px wide version for the view image page, and then finally the full-size original image for HD viewing, but I also need to apply a watermark, but only to the full res version. And I need help with an image upload script. Any sort of file upload, really. I've looked at tutorials, and they don't seem to make too much sense. Furthermore, I need to drop all three versions into a database row (which I think I can figure out). I know that I need to use something like $_FILE to do it, but I'm just really confused to the actual usage and the cropping/resizing/watermarking part really has me stumped. Solutions, anyone?
File uploading
Upload using a simple HTML form and use PHP to manipulate the image. Example
Read all the images stored in a directory and convert them in a batch. Example
Image re-sizing
Use ImageMagick or GD library to resize images. Example
Use any of the same libraries to watermark the images. Example
In all, you need to combine all these in order to upload, resize and watermark all in one go.
For the resizing, watermark etc, you should look at ImageMagic
I want to get remote images and resize them and store them as well as storing the original images.
I would like an option to regenerate images /thumbnails as well, so they are updated automatically.
The types of images that should be allowed are gif and jpeg
If possible then gif should also be converted to jpeg.
Anyone has simple class or function to do this?
Get remote images: curl or (assuming allow_url_fopen) simply fopen
Resize Images: gd or imagemagick
I'm going to create a new JPG image with PHP. How can I set the DBi value of a new JPG image.
Dirk
JPG is a Pixel format that doesn't really know physical dimensions like Dots Per Inch.
All you can do is write a dpi value into the file's Metadata as assistance for further processing, but it's just a recommendation and it can't be done using the GD library.
You would have to use an third-party library for this. See e.g. the second answer to this question: How do I add exif data to an image?