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).
Related
I want to all images that will be stored on server to be maximum 900px width.
Example:
User uploads image with 3500px by 3500px, i need it auto resize for 900px and then delete original 3500px image from server. Thanks
To generate different sizes of images, you can add custom thumbnails that will be created when an image is uploaded. You can achieve this with a couple of lines of code in functions.php:
https://developer.wordpress.org/reference/functions/add_theme_support/
I'm not sure deleting the original is possible, as it's linked with the different thumbnails that are generated. A couple of tweaks in your template do however ensure the original isn't used.
What is the best way to fit an image for thumbnail example 200px x 200px ?
after researching here are the best options I found:
save 2 set of images for thumbnail and large slideshow purpose, for example if user uploads img001 , then save 2 copies of the same image one for thumbnail(resized 200px x 200px) and one for large slideshow purpose(actual dimension).
just use one image and use it responsive with 100% width and 200px height(for thumbnail) and let the large image be itself.
with solution 2 I found that the thumbnail image always look shrunk.
Please give some suggestions on dealing with thumbnail images, thanks in advance
Here is what i suggest.
Store only one original image at the time of saving.
Maintain a Cache folder for your images in such a way that the cached images are created whenever you need to display on whatever size you want.
eg : make a function something like
getCachedImage($post->image, '200x200-','200','200')
and inside that function you can have some logic to save a precise sized
image you want inside cache folder. Dont forget to check if the following size image is already been saved. You can use size as prefix ('200x200-$fileName') as i have mentioned on example. I use Image Intervention Package for my laravel project to save those picture in the size i want it to display.
Now you can call this function in your view wherever you need to display an image and you can call any size image you want.
You will always have shrunk image if you use your option number 2.
And Even in your option 1, if you saved one extra image as thumbnail you will never have exact needed size for you thumbnail, so at some place this thumbnail is also gonna shrink.
I have an ecommerce site in which i have to display some products i.e 40-50 products per page.Every product has an image which displays the image of the product.
The main thing is that in the database i have a meduim/high quality image of the product whose dimensions would be around 720px-1024 px , these can vary and every image has dimensions in between these two.
Now, i have two different ways of displaying these images for product, i could use a php script to generate thumbnails from these pics whose dimensions would be 290X290 or i could use the style tag and set the width and height as 290X290 and source as the real image.
Let me explain this by an example.
Original Image
I could do this to display the image
<img src="/imagethumbnail.php?product_id=34"/>
<img style="height:290px;width:290px" src="productimg.png"/>
finall image
one calls a php script and generate a thumbnail image of size 290X290 while the other one simply uses the style tag.
Both of them are working fine but i think when i use the style tags i see a trade off in image quality.While when i use the script to generate the image i see a trade off in image generation like they take sometime to show up on the page.
What would be the better method to do this and what would be the perfect solution towards it?
I think the standard method is to generate the thumbnails in advance. And you should probably set the width and height in the markup as attributes on the img element, rather than under the style attribute.
I'm resizing larger images contained in posts for my site teasers using ImageCache (Drupal 7), and for some reason the quality of the images goes down significantly when I size down (e.g. 670x400 pixel image is sized down to 220x185). Quality doesn't usually go down when sizing an image down (only when sizing up?)
Does anyone know how I can fix this?
Thanks.
In back-end, under Configuration/Media/Image toolkit you can set the JPEG quality.
URL is:
/admin/config/media/image-toolkit
You can set a specific image style (image cache) preset for the node teaser from content type Manage display page. e.g. ?q=admin/structure/types/manage/[CONTENT_TYPE]/display/teaser
Click the gear icon next to the image field, and choose the image style you want to apply to the content type's teaser display.
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...