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.
Related
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);
}
I need to resize the users' avatars to be 150x150 px after they upload. The thing is, my employer wants me to not use a PHP library, but a Zend one, and I couldn't find any. Is there a way to do this ?
There is no such method in zf2. But you can write filter that will wrap this behavior:
take Zend\Filter\File\Rename.php as an example and alter it to use your preferences.
I would probably use php-imagick commands like:
$imagick = new \Imagick($path);
$imagick->resizeImage(217, 0, $imagick::FILTER_LANCZOS, 1);
$imagick->writeImage($thumbPath);
$imagick->clear();
I want to be able to generate image thumbnails without saving them to the server. So far, I've come up with this code, but I'm not sure what to do with $code.
$code = system("convert galleries/13_0.jpg -resize 400x270 /dev/stdout");
How would I go about plugging $code into the PHP/HTML to get the raw image code to display as a jpg?
I would advise you not to do this from the system as you have described.
PHP has libraries for doing this sort of thing.
http://www.php.net/manual/en/ref.image.php.
http://php.net/manual/en/book.imagick.php.
And there are libraries the wrap these native functions for manipulating images. https://imagine.readthedocs.org/en/latest/
That way all your code is in PHP and you are not relying on the system to do anything (providing PHP has been compiled with the libraries as described. They are standard libraries available in most PHP builds and you can enable them if they are not included).
Edit: I'm advocating that you.
Open the source image.
Convert the source image
Return the source image
with imagine you would do it thus:
$imagine = new Imagine\Gd\Imagine();
$size = new Imagine\Image\Box(400, 270);
$imagine->open('/path/to/large_image.jpg')
->resize($size)
->show('jpg');
If the $code is the raw data, could you have another file getimage.php which would write the data out but set the header content type to image/JPEG? So your img src would be getimage.php?image=13_0.jpg for example?
I would save it to memory, then read it, then delete it. /dev/shm is a ramdrive on most Linux systems.
$tmp = '/dev/shm/'.uniqid('',true).'.jpg';
system("convert galleries/13_0.jpg -resize 400x270 $tmp");
header("Content-Type: image/jpeg");
header('Content-Length: '.filesize($tmp));
readfile($tmp);
unlink($tmp);
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.
is that possible to show whole php page as an image file like png or jpg ?
for example,
<img src="details.php?id=44">
just like a screenshot of the page.
Thx
<?
// details.php file
// {
// do stuff to create your image and store in $my_image
// }
header("Content-type: image/jpg");
echo $my_image;
?>
1) output the mime type in the header.
2) echo your binary data
easy!
Not in the way you're thinking. You can use the PHP ImageMagick library or the PHP GD Library to generate an image dynamically and output it, but in order to get screenshots of a page you'll really need an outside service.
it depends on what you want to show. if its html/js/css, it varies across browsers.
If its unicode text to be displayed as images, you can use GD library for the purpose
I think you are talking about taking screenshots of a url or webpage. You can you freely available like:
http://www.shrinktheweb.com/
http://picoshot.com/
There are many such freely available services. If you want to host such service on your own server. You will need to create a software which can open your browser and take screenshot of the url. Ther are some softwares available as well. I hope it helps.