I want to blur images dynamically, but it has to be a very strong blur, so it can only be assumed what the real image is.
I read this question where imagefilter is used. But this solution didn't blur my image enough.
Somewhere I also read that it's too old and not modern anymore to use Imagick. Is this true? What is the best method in the modern standards of 2016/2017 or is even a good php class out there?
If I'm using Imagick like in this example on PHP.net do I have to include a file with this image header to display one or more images on a webpage or is there a way to use Imagick without setting an image header?
Try this...
for ($x=1; $x<=15; $x++)
{
imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR);
}
Related
For one of my scripts I need to check if gif images are transparent (have transparency) using php. Note, I only need this for gif images.
My sincere apologies if this has been asked. I couldn't find anything that answers this question or works.
After looking through some documentation there does not appear to be any quick and dirty way to find out if a gif has a transparency.
The only way appears to be to use a library like GD or Imagick.
Sorry, only possible with GD:
$image_original = imagecreatefromgif($image_file_path)
if (imagecolorsforindex($image_original, imagecolorstotal($image_original)-1)['alpha'] == 127) {
echo '<strong style="color:crimson">TRANSP. GIF</strong>';
}
I use the below code to create polaroid effect, but its really distracted without any transparent effect around.
<?php
/* Create the object */
$image = new Imagick('wood.png');
/* Set the opacity */
$image->polaroidImage(new ImagickDraw(), 25);
/* output the image */
header('Content-type: image/png');
echo $image;
?>
I get result like http://photoapp.biz/polaroid/test.php
Orginal image is http://photoapp.biz/polaroid/wood.png
What will be the problem? This occurs in almost all 10 images I've tried.
Example:
Correct me if I'm wrong but you are really asking about anti aliasing, aren't you?
http://www.imagemagick.org/Usage/antialiasing/
Transparency is set with Imagick::setImageOpacity
$image->setImageOpacity(0.7);
Besides maybe you need to work with another image format:
That said, some web browsers however do NOT display transparent "PNG"
images correctly (most notably Microsoft Internet Explorer v6, though
IE v7 does). Because of this I generally prefer to use JPEG and GIF
image formats, and only use PNG when generating images with
semi-transparent pixels, or requiring a exact colors for later
examples.
Source: http://www.imagemagick.org/Usage/#PNG
EDIT 1
try
$image->setBackgroundColor(new ImagickPixel('transparent'));
Try this function http://php.net/manual/en/function.imageantialias.php.
What it does is:
Just be aware that IMAGIC can be compiled in many different ways and you might have different effects across different environments.
I want to have a system in my Joomla website where user can upload their image and create and design a product image by having the product template. For example the keychain needs to be design.
Can any one recommend is this possible with PhP? or I need some other platform to work on.
Thanks
This can be done with GD or Imagemagick libraries for PHP.
Here is a sample script I wrote a while back to composite an image to a blank coffee mug using PHP and imagemagick. This should be very similar to what you're trying to do.
<?php
$im = new Imagick('image.jpg');
$mug = new Imagick('images/mug.png');
$im->scaleImage(300, 0);
$im->setImageFormat('png');
$im->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
$im->setImageMatte(true);
$height = $im->getImageHeight();
$mug->compositeImage($im, $im->getImageCompose(), 80, 130);
header("Content-Type: image/png");
echo $mug;
?>
If you want to provide a kind of graphic editor to users most likely you need a JavaScript implementation with PHP only handling the final result of it.
A common way to edit images with PHP is to use Imagick, but your case doesn't really sound like that. This is more applicable to, say, cases when you need to resize all the uploaded image or to save them in a different format.
I use Soundcloud for my tracks.
I'm using their jquery player to place a widget on my new site, as you can see on the top right:
The problem is, the waveform Souncloud provides is a one colour only deal:
My goal: To change this waveform PNG from curent colour to black, but client side.
I know I can change things using PHPs GD library, and I've done this successfully with a test image on my server using this code:
http://php.net/manual/en/function.imagefilter.php
(Search for "IMG_FILTER_BRIGHTNESS")
<?php
$im = imagecreatefrompng('hello.png');
if($im && imagefilter($im, IMG_FILTER_BRIGHTNESS, -255))
{
echo 'Image brightness changed.';
imagepng($im, 'hello.png');
imagedestroy($im);
}
else
{
echo 'Image brightness change failed.';
}
?>
It works perfectly! BUT
It changes the actual image on my server! Pretty cool, but not possible...
Obviously I cant change the image on Soundcloud's server (all the data, images, music comes from there API)
So What I'm looking for is a way were I can change the colour of the PNG client side, on the fly. I have a lot of tracks on there, so basically each time the user clicks next or previous, the waveform loads in and before it does it needs to change that image's colour :-?
Is this possible?
To see the player in action on my test site
(the styling on that one is old, by the way, but it's functionality is correct)
http://marckremers.com/2011/
NB the entire site does not work beyond what you see there. Still a WIP.
Thanks so much
This would have to be done client-side using Javascript, either a fully JS solution or one that uses AJAX to send it to PHP, then receives the final image.
You can try the Pixastic JS library:
http://www.pixastic.com/lib/docs/#intro
If that doesn't work, I would use jQuery to read the image, send it to a PHP script using JSRS/AJAX and then replace it on the page.
I am working on a new site and would like it to be able to add effects to photos uploaded. (Blur, Pan, Swirl, Sparkle, Border, Frames, etc ) I would like the photo manipulation to be in PHP if possible. I need the user to be able to upload the photo, make the edits, then save the edited photo to their computer.
This may be better as a separate question, but if at all possible I would also like the user to be able to save the edited image as their Facebook profile image.
Try PHP extensions for ImageMagick It's a standard, tried and true image manipulation library.
From the homepage:
Use ImageMagick to translate, flip,
mirror, rotate, scale, shear and
transform images, adjust image colors,
apply various special effects, or draw
text, lines, polygons, ellipses and
Bézier curves.
If you consider using the MagickWand PHP extension:
The MagicWand docs start off with a nice PHP code sample shown here:
<?php
$magick_wand=NewMagickWand();
MagickReadImage($magick_wand,'rose.jpg');
$drawing_wand=NewDrawingWand();
DrawSetFont($drawing_wand,"/usr/share/fonts/bitstream-vera/Vera.ttf");
DrawSetFontSize($drawing_wand,20);
DrawSetGravity($drawing_wand,MW_CenterGravity);
$pixel_wand=NewPixelWand();
PixelSetColor($pixel_wand,"white");
DrawSetFillColor($drawing_wand,$pixel_wand);
if (MagickAnnotateImage($magick_wand,$drawing_wand,0,0,0,"Rose") != 0)
{
MagickEchoImageBlob( $magick_wand );
}
else
{
echo MagickGetExceptionString($magick_wand);
}
?>
Similarily, documentation for things you seek:
blur
swirl
frame
magnify
and a plethora of others.... On that the main documentation page see all methods listed by searching for the heading: "MagickWand For PHP Methods".