PHP thumb resize png image but add black background - php

I am using PHPThumb to resize images rumtime. It is working fine but it add black background on PNG image.
How could I resolve this?
my path is
phpThumb/phpThumb.php?src={imagepath}&w=95&h=92

Here is the example to avoid black background:
src="/uploads/phpThumb.php?src=images/expressionengine_logo.png&w=100&f=png"
src="/uploads/phpThumb.php?src=images/expressionengine_logo.png&w=100&bg=D4E9F7"

Well, I am not familiar with PHPThumb but you can use SimpleImage library with this update.
I am using it and didnt faced any problems yet. This library has purposefully updated for the problem you are facing right now. Go to the links and try to use it.

Try replacing ImageCreateFromJPEG($file) with ImageCreateFromPNG($file)
Most probably this is the common error for the black background in the resized pngimage

Related

How to resize video for mobile mode in wordpress/php?

Hi so I added a video into the front-page.php code using the following code:
<div style="text-align: center" id="video">
<iframe width="867" height="488" src="https://www.youtube.com/embed/6c7Fx2PR9Dk" ></iframe></div>
(sorry for some reason the code editor is not working)
however when I try to change the width and height in the mobile mode using #video, it does not change. any help is appreciated!
EDIT: I added a class=container and changed the width to 100% and height to auto. This worked a little better but now the height of the container needs to be bigger. I cannot seem to find where to add the code to edit it.
I cannot see your code but I am sure it would be way easier to achieve this using CSS and media queries. Assuming your video player is configured to take 100% of the width of the container it sits in.
Actually you have to use the following cass to make it full width
#video iframe {
width:100%!important
}
Fitfids.js is really nice plugin to make the iframe, video embeds responsive. You may try to use that for your ultimate video responsive solution.

Display resized image programatically without creating another image on server

Is there any library or script which would allow me to display the resized version of an image programmatically? without actually creating another resized image and saving it into the server?
I am looking for something like this, ie:
<img src="script.php?image_path=/mysite.com/public_html/img/my_image.jpg&new_width=300&new_height=100" />
Is it possible? Does it exist?
I hope I am making sense here...
Thank you very much for your help! :o)
You can use Cloudinary to programmatically resize images based on the resolution of the viewing device. All you need to do is basically mention the height and width parameters and it transforms the image on-the-fly:
<?php echo cl_image_tag("my_image.jpg",
array("width" => 100, "height" => 150, "crop" => "fill"));
?>
For more examples on re-sizing that suit your specific use-case, you can refer the the documentation here:
http://cloudinary.com/documentation/php_image_manipulation#resize_crop_and_thumbnails

Combine two images (.JPG) using PHP GD

I can't find a solution to this. I want to add 20px empty space to this image:
http://img233.imageshack.us/img233/419/78317401.jpg
and then paste this watermark at the bottom (on the blank space)
So the output would be:
http://img252.imageshack.us/img252/4554/wynik.jpg
I don't want to stretch it.
EDIT
Did it with WIdeImage. Rly simple.
1) Load both images with
http://www.php.net/manual/en/function.imagecreatefromjpeg.php
2) Get 1st image height and width with
http://www.php.net/manual/en/function.imagesy.php
http://www.php.net/manual/en/function.imagesx.php
3) Create larger image with height+20
http://www.php.net/manual/en/function.imagecreatetruecolor.php
4) Copy the first image and the second image to the larger image
http://www.php.net/manual/en/function.imagecopy.php
5) Save it
http://www.php.net/manual/en/function.imagejpeg.php
6) Done
Try wide image api http://wideimage.sourceforge.net/
Check out one of their this demo may be that help you
Merge and
Resize

Is it possible to change image position and width with php GD?

I have a gif file with many icons and buttons on it..
What I want to do is include that gif file using php gd somefunction("file.gif")
then, resize the new image to 30px by 30px.. and then be able to position (using x and y coordinates) the actual gif file, so that only a certain area of the image shows on the new file..
just like the css background-position property but, with gd.
Thanx
imagecopyresized() resizes the image, so it doesn't quite work for what I was exactly looking for.
For anyone else that might need this, the best function is actually imagecopy().
http://www.php.net/manual/en/function.imagecopy.php
It will do the trick..
Thanx Trufa for the quick answer though.
imagecopyresized()
http://www.php.net/manual/en/function.imagecopyresized.php
Should do the trick for adjusting the size.

Image decoration

How can we do image decoration in PHP, e.g. adding text or an image to it?
With GD and/or ImageMagick usually.
This tutorial can help: http://www.prodevtips.com/2009/09/10/image-manipulation-and-watermarking-in-php-with-gd2/

Categories