Does anyone know how to make a .ico file that will work in Intenet explorer?
I can't seem to get anywhere
here is my gd code
$im = imagecreatefromjpeg(FAVICONDIR.'normal/'.$filename );
list($width, $height) = getimagesize(FAVICONDIR.'normal/'.$filename); // get the width and height of the jpg
$image_p = imagecreatetruecolor("16", "16"); // create a 16x16 canvas to play with
imagecopyresampled($image_p, $im, 0, 0, 0, 0, "16", "16", $width, $height); // resize jpg to 16x16
imagepng($image_p,FAVICONDIR.'icons/'.$ico_filename); // make a .png file (icon file) from our data
imagedestroy ($im); // close gd library
and an attenpt with image magick
/*$cmd = IMAGEMAGIKDIR .''. FAVICONDIR.'normal/'.$filename . ' -transparent white -background white -flatten -resize 16x16 ico:'.FAVICONDIR.'icons/'.$ico_filename;
exec($cmd);*/
Any ideas would be great.
Use png2ico if you run into problems this is a great tutorial
http://myutil.com/2007/10/14/favicon-ico-gimp
Richard
Related
Below is my image generate code:
$thumb = imagecreatetruecolor($newwidth, $newheight) or die('Cannot Initialize new GD image stream');
print_r($thumb);
$source = imagecreatefrompng($filename) or die('Cannot Initialize new GD image stream');
print_r($source);
imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
#imagepng( $thumb, $original_img_dir_absolute_path.$original_img_name, 0 );
it will generate first png but with black background only.
anybody have idea about it.
Your code seems to be OK. You may check if the fragment does not take a black part of the original image. You can also try to remove your "quality" parameter of imagepng() :
imagepng($thumb, $original_img_dir_absolute_path . $original_img_name);
Maybe your original image have a low contrast, and the low quality shows you a black image.
Is it possible to have png images on my server but have a php script that converts them to jpg (and compresses them) and caches them when viewed?
You can use this script for convert PNG image into JPEG image.
$input_file = "test.png";
$output_file = "test.jpg";
$input = imagecreatefrompng($input_file);
list($width, $height) = getimagesize($input_file);
$output = imagecreatetruecolor($width, $height);
imagecopy($output, $input, 0, 0, 0, 0, $width, $height);
imagejpeg($output, $output_file);
You can go through this #Alexandre Jasmin Answer.
yes it is possible, you can google it using phrase "png convert to jpg php"
Use PHP to convert PNG to JPG with compression?
I'm trying to add a watermark to a video file but i'm having problems with the background of the watermark because i want it to be transparent.
My approach is like this: i make a png file the size of the video with transparent background like this
$im = imagecreatetruecolor($width, $height);
$almostblack = imagecolorallocate($im,254,254,254);
imagefill($im,0,0,$almostblack);
$black = imagecolorallocate($im,0,0,0);
imagecolortransparent($im,$almostblack);
$textcolor = imagecolorallocate($im, 255, 0, 0);
// Write the string at the top left
imagestring($im, 5, 0, 0, 'Hello world!', $textcolor);
imagepng($im, $img);
imagedestroy($im);
and then i add it to the video like this
exec("/usr/bin/ffmpeg -y -i '$file->path' -sameq -vf 'movie=$img [logo]; [in][logo] overlay=main_w-overlay_w:main_h-overlay_h [out]' '$new_path'");
the watermark is added but it's background is not transparent.
Any idea what i'm doing wrong ?
UPDATE: it turns out it works just fine for other png images so the problem must be in the way i build the png file any ideas why it doesn't work that way ?
I am using PHP to rotate an PNG image, with a transparant background. But whatever I try, there are still some black lines around the original image.
How do I remove the black lines. Everything else works fine. The image is transparant, the image is rotated, the new corners are also transparant. Just the black lines around the original square (which is rotated) are annoying me.
I use this code:
$angle = -100;
header('Content-type: image/png');
$image = 'http://mapning.com/img/plane.png';
$file = imagecreatefrompng($image);
$rotate = imagerotate($file, $angle, 0);
imageSaveAlpha($rotate, true);
ImageAlphaBlending($rotate, false);
$transparentColor = imagecolorallocatealpha($rotate, 200, 200, 200, 127);
imagefill($rotate, 0, 0, $transparentColor);
imagepng($rotate);
I found my answer here:
http://ru2.php.net/manual/en/function.imagerotate.php#47985
I think better use imagick
Here is an extension for PHP
Or if you want with GD see here
http://ru2.php.net/manual/en/function.imagerotate.php#46338
I am working to resize and resample some jpeg images using PHP. It take any image greater than 500px by 500px and make the largest side 500px. This should be relatively simple but every time I run the script it makes a black jpeg. The jpeg created has the proper dimensions but does not include the resized image. The GD library is enabled, and I have made sure it is finding the original image. I've been looking at this block of code for a day and half with no luck, what am I not seeing?
<?php
$testimage = 'SandyCayCaribbeanbeach.jpg';
$testfolder = "testimage/testimage.jpg";
list($orgwidth, $orgheight, $type, $attr) = getimagesize($testimage);
echo "org. width " . $orgwidth . "px" . "<br />";
echo "org. height " . $orgheight . "px" . "<br />";
if($orgwidth > 500 || $orgheight > 500){
if($orgwidth > $orgheight){
header('Content-type: image/jpeg');
$ratio = $orgwidth/500;
$newwidth = floor($orgwidth/$ratio);
$newheight = floor($orgheight/$ratio);
$image_p = imagecreatetruecolor($newwidth, $newheight);
$image = imagecreatefromjpeg($testimage);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($image_p, $testfolder, 100);
}
else{
header('Content-type: image/jpeg');
$ratio = $orgheight/500;
$newheight = floor($orgheight/$ratio);
$newwidth = floor($orgwidth/$ratio);
$image_p = imagecreatetruecolor($newwidth, $newheight);
$image = imagecreatefromjpeg($testimage);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($image_p, $testfolder, 100);
}
}
?>
Firstly make sure you have error reporting turned on. Also make sure it can find the source image "SandyCayBaribbeanbeach.jpg".
A simple if(file_exists()) check before handling the image resizing will help trap errors.
I found that I had to specify a full path to the image, not a URL i.e.
/path/to/image.jpg
instead of
http://www.blah.com/image.jpg
to get this to work properly. Hope it helps someone.
Double-check to make sure your source image is truly a JPEG. If you are running Windows, open it up in MS Paint and re-save as a JPEG. This will help rule out the possibility of it being a different format.
I also fought this for a while in a piece of my code recently, and found that imagecopyresampled will even return 1 if the dimensions are not defined. Make sure that your source height and width are set.