How to increase image size without scale image with php - php

I want to change .webp image width or height to a higher value, and add some transparent area to the image.
For example, imagine I have a width:512*height:312 webp image, I need two steps:
1- Add 512*200 transparent area to my image.
2- Transform my image to the center of the new image.
OR
1- Add 512*100 transparent area to the top of my image.
2- Add 512*100 transparent area to the bottom of my image.
The final result I want, a 512*512 .webp image without any scale on my original image.
How can I do this with the PHP language?

Consider using Imagick extension.

Related

Checking if Thumbnail and Full Image are a match in PHP

I have a large database with images. Problem is, quite some images have the wrong thumbnail, so I need to confirm that they match.
I want to compare the thumbnail and full size image with each other, and come up with a percentage that they match.
The thumbnails & full images do not have exactly the same dimensions.
The full images are PNG's with transparent backgrounds, and the thumbnails have a grey/white grid as a background.
What is the best way to see if a thumbnail & full image match?
Example of how a full image & thumbnail look.
I found & tried: https://github.com/kennethrapp/phasher but this gets thrown off by the grid background in the thumbnails.
I had nearly the same problem and my solution was that I compare the timestamp of the full size image with the one of the thumb. If the thumb is older, then a new full size image was uploaded and my system creates a new thumb (and also clears the according cache).

Mask/Merge an image to another image in PHP GD

I have a requirement I need to merge/mask an image to its cover image. please see below pics
Cover image- (png mask)
Customer Photo
Final Image
Is this possible in PHP GD? Finally it should generate a single image.
Thanks!

Creating a center-aligned thumbnail from image

I'm trying to make a site with images on it, but I don't want to have the traditional thumbnail (where it's just a smaller image), I want something like this: http://imgur.com/r/funny
Notice how all the images' thumbnails are 160x160 and only shows the center of the image. I'd like to do something along those lines.
First, in PHP you use the gd-lib for such things.
The task goes this way:
Open the original-image with imagecreatefromXXXX: http://php.net/manual/de/function.imagecreatefromjpeg.php
Get the image-boundaries with imagesx() and imagesy()
The way you want to resize the images is: "Get the smaller side of the original-image and resize the image proportional. So, that at lease one side matches the corresponding resulting image's side". The ticky thing here is, when you have an targeted size, where horizontal- and vertical size are not equal. eg. 170x120.
Then you create a new image and resize/copy the original image with imagecopyresampled() into that.
You have now an image where one side is equal to the respective target side. The other side is bigger or has the same size as its corresponding size on the target image. The next step is to crop this image. This can also be done with imagecopyresampled() - also in the same step, were you resized the image.
Now save the image under a new filename (or in another directory) and link it...

Image upload in a registration form with image preview and cropping tool using PHP yii framework?

How can I upload an image in a registration form with image preview and cropping tool using PHP yii framework?
I have a user registration form in my yii framework and want to include an image upload for the user image. I want that the image in uploaded and directly displayed in the form after the upload was successful. After that I want to resize and crop the image and when the create user form is submitted the image should be saved and the user record should contain the url to the image in order to display it later.
How can I set a fixed size for the image to be stored? I.e., when I want to have the image in width 200px x height 300px for example.
For live preview before updating you can use html5 File API.
I advice you to look in these links:
file-api-example
https://developer.mozilla.org/en/Using_files_from_web_applications
For cropping images on the server side, please use following yii extension:
http://www.yiiframework.com/extension/image/
You can also let the user crop image on the client side. You can define the fixed aspect ratio and let the select part of the image. I personally use Jcrop javascript library.
You want to have the image to be 200px x 300px. AspectRadio is 0.67 in this case. You define aspectRatio in Jcrop:
jcr = $.Jcrop('#imageDisplay');
jcr.setOptions({
trackDocument: true,
aspectRatio: 0.74,
Since your aspect ratio is fixed, you only have to resize the image to 200px x 300px using the mentioned extension.

How to make an image zoom even when it changes?

I'm trying to make a script that zooms into an image. This is the page:
http://vermilionsite.com/phone/?id=1
Click the first option, then choose a colour, then mouseover the image. It uses the original image. How can I make it so that the zoom uses the new coloured image?
The jQuery function you have just adds a div with a background over the image, while the original mouse overlay function that zooms your image moves the 'bg-iphone.png' background around in an overlay, so the logic is somewhat flawed as you would also need another background image with the same color on the original div so a bg-iphone.png modified with the same color. I guess you could modify the script that returns your color overlay to also return a modified image and change the background of the image from bg-iphone.png to a png with the same color as the overlay.
Or you could have three modified pngs with the same colors you need that would change the background image in the select function.
Hope this helps.
use this http://www.userdot.net/files/jquery/jquery.loupe/demo/

Categories