Image decoration - php

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/

Related

PHP thumb resize png image but add black background

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

Setting comment box size or style (font size) in comment?

Is it possible now to define size of comment box generated with PHPExcel? Or to define its style?
The width and height can be changed using setWidth and setHeight commands, as follows:
$objPHPExcel->getActiveSheet()->getComment("A1")->setWidth("400px");
$objPHPExcel->getActiveSheet()->getComment("A1")->setHeight("250px");
Yes it is possible with php spreedsheet :
` $spread->getActiveSheet()
->getComment('G1')->getText()->createTextRun('Hello World!);
$spread->getActiveSheet()
->getComment("G1")->setHeight("400px");
$spread->getActiveSheet()
->getComment("G1")->setWidth("400px");`
The comment content can be styled using rich text runs; but the box itself cannot be styled or resized using PHPExcel

svg to image on demand

I have javascript code that generates svg image tags on the fly when a person lands on one of the pages. Im using the d3 library to help make the image. The only problem is that d3 is not fully IE compatible and I would want to generate a .png, jpg, gif or any other image file based on the svg file. Is there a known way to do this?
The server side code is PHP based, and we use node.js, and render.js for a lot of the dynamic content.
I'm using ImageMagick to convert SVG images to PNG images.
This works pretty well.
A quick example of how to do this:
exec('/usr/bin/convert /path/to/image.svg /path/to/output_image.png');
I'm using this with great success for processing QR codes made with libqrencode to different sizes and colors.
Firstly you need to use a DOM implementation on server side as you want to get svg which is rendered on client side.For this we use jsdom with node.js.
Using this you can render D3 on server side and get svg on server then convert it to any format you like.
Here is the link on how to that.
Once you got SVG and PNG then by using modernizer.js
1)Check compatibility of browser using Modernizr.
2)Then load SVG or PNG basing upon on the compatibility.
Example (JS solution):
if (!Modernizr.svg) {
$("#logo").css("background-image", "url(fallback.png)");
}
Example (CSS solution):
.no-svg #logo { background-image: url(fallback.png); }

PHP video snapshot display

Is there any way to display video(snapshot) as as a image in PHP?
There is an option without generating a new snapshot, simply using html code :) easy, isn't it?
<video src='DIRECCION_DEL_VIDEO' width='100px' height='60px'/>
Hope you enjoy it!
Regards,
Jose Romero
Well You can create thumbnail using ffmpeg .
Then you can simply execute that command from php using exec. You can show created thumbnail then as you want.
You can check
http://flowplayer.org/tutorials/generating-thumbs.html

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.

Categories