Using Photoshop Actions on Images uploaded by Users - php

I want to have a user upload a image to my website and have a series of Photoshop actions like adding a layer behind of that image, a layer infront and some dynamic text with effects applied to it like drop shadow and gradient overlay. Is this even possible?

Have a look at Various Image Processing and Generation functions provided by PHP mainly ImageMagick & GD. If that does not prove to be sufficient,
Consider Gimp command line. you can easily invoke it from php using exec() function. GIMP is full featured & can do almost all fancy Photoshop actions you would want. And its free!
Hope it helps

PHP libraries are available to perform some basic graphics manipulation, as mentioned in the other answer. If these aren't adequate for you, it looks as though you can run and script the normal Photoshop program on your server. Photoshop is not available for Linux, so you'd probably need a Windows server. (This wouldn't be doable on shared hosting, you'd probably need a decent VPS at least.)
I haven't done this before, but according to Adobe Photoshop Scripting documentation your language choices are JavaScript and VBScript. Someone could write a PHP library to access this, but I don't know of anything like that.

Related

Creating an image from an HTML document at runtime

I am currently working on a website project that requires the creation of an image based on user input on a form. Basically, I'm trying to create an image from existing HTML markup with the form data replacing some of text. The text is almost always unique.
I have explored several options for creating such an image, mainly:
imagecreate with PHP that wasn't flexible enough, and
PhantomJS which I can't really install on the server
wkhtmltopdf and php-wkhtmltox
I am working in a shared-hosting environment that limit my available options. The environment supports PHP (compiled with GD), Perl, and Python.
Is there a reliable way to implement such a behavior?
I use CutyCapt software to render images from html, it works perfectly. The only issue is that you need to build it on your shared hosting. Probably the workaround could be in building it on your local machine, uploading it to your hosting and running it from there, but I don't believe it will work, because it requires X server.
Another possible solution could be use of GD library to build the image manually. If you know how your html is looks like, you can replicate it by drawing all elements on a blank image. It is not easy to do, but looks like this is only one solution which you can use.

Multiple HTTP File Uploads

I'm looking for a tool to facilitate mulitple webpage file uploads from a single file browse dialogue. I know this has been asked previously, but I can't find anything current.
I'd like to check file size prior to upload, and I gather Flash is still the only way to do that cross-browser?
Ideally, I'd like an upload progress metre. I'll be using Linux and Apache servers, but don't have access to install add-ons such as PHP APC. Again, I assume something flash-based is the only option there?
I've looked at SWFUpload, but that appears to be another of these projects where the developers have become quite zealous and turned a simple concept into a full suite of tools for the masses. It seems quite cumbersome and I don't think I want to use it for my purpose.
I'd prefer not to have to write something from scratch for this. Could someone recommend me something or perhaps suggest a non-Flash alternative if there is one? I do need full cross-browser compatibility without too many layers of degradation, so anything HTML 5 probably isn't what I want.
Thanks
As I mentioned earlier today ( Multiple file upload (client side) )
I am a big fan of Plupload which can check file size, show progress bar, single dialog for multiple files, and supports things other than Flash if needed.

RAW images and PHP

I would like to extract a thumbnail from a RAW image file, like Canon's .CR2 or Nikon's .NEF. I've understood that this can somehow be done with ImageMagick, but haven't grasped if it's possible through the PHP wrapper.
Are there any good solutions? Preferably using the built in thumbnail for speed.
Yep, iMagick (the php version of ImageMagick) can handle these extensions: http://www.imagemagick.org/script/formats.php
Here's a great set of tuts that got me going with Imagick. The owner responded to a few of my questions quickly, and despite a bit of a language barrier was able to easily get me through my hurdles
As an aside, I've begun using Gallery to do image admin. No need to worry about thumbnailing, uploading, etc....it's all automatic. Then on the front end I can do jquery magic (getting photos via php query from the gallery database tables) to make it look really good.
Likely, if PHP's imagemagick libraries are to support this, they would be drawing from some functionality exposed through imagemagick's 'identify' command line tool (as the tool would be itself exposing functionality in the imagemagick libraries). Looking at the documentation for this tool, it doesn't look good. If you tried running identify -verbose, theoretically, the thumbnail information would appear in there somewhere, perhaps as an encoded value. Try it yourself: if it does, maybe you could possibly further extract the information returned from identify, either through the imagemagick functions in PHP (though I don't see any past the Exif libraries which only work on JPEG), or by scraping the return of a PHP system call to the identify tool.
Either way, doesn't look likely.
Benjamin Horn has submitted a complete example about reading the requested data and even saving it locally for later use.
Check this out:
https://benjaminhorn.io/code/extracting-thumbnails-from-camera-raw-files-cr2-and-nef-with-php/

Server-side conversion of raster images to vector images

I would like to convert images that have been uploaded by the user (in various formats and conditions) to a vector image format such as .eps. I'm primarily working in PHP.
What options exist?
There are a small number of autotracing software projects released under GPU (for example, POTRACE that you could run via system commands. I can't attest to their quality. Tracing almost always requires some element of human supervision to avoid things looking like a mess of broken pottery, but you won't know until you try. Rather than triggering the tracer via PHP, I would use PHP simply to save incoming images to a temporary folder and then, through cronjob (one- or two-per-minute), crank through the holding folder in batches (you could pace it that way and avoid it being used as a way to DoS your site).
I'm thinking of doing something slightly similar (though not graphic related) for an upcoming project, and I'm considering doing all my heavy lifting on a desktop machine, which would fetch all incoming files and process them before FTPing them back to the server. I'm somewhat nervous about having any complex resource-intensive script like this running on a web server.
Definitelly you can do this with the Inkscape
here is the list of formats it supports What formats can Inkscape import/export?
and it can be of course used with the command line or exec() command Can Inkscape be used from the command line?
Imagetracer is a free and open source (Public Domain) library and application which can be used on the server side. Disclaimer: I made these.
You can use ImageTracer.jar from
https://github.com/jankovicsandras/imagetracerjava
like this with PHP:
<?php exec("java -jar ImageTracer.jar input.png outfilename output.svg"); ?>
You can also use the JavaScript version with Node.js on the server side, here's the example code:
https://github.com/jankovicsandras/imagetracerjs/tree/master/nodecli
https://github.com/jankovicsandras/imagetracerjs/blob/master/nodetest/nodetest.js
PHP is not an image editor. It is a hypertext preprocessor.
You have to move to serverfault.com, or even better on some image processing resource, and ask there for some command line utility that can be run from PHP using the system() command.

How might I obtain a Snapshot or Thumbnail of a web page using PHP?

I need to create Snapshots / Thumbshots / Site preview a-site.com.
There are some site as thumbshot.org that meets with I need. But I do not want to use an external service, not to depend on others for my project (What would happen if they close the site?)
For this reason, I am looking for some project to let me do this.
Any idea?
On windows you can use GD's imagegrabwindow() function.
Edit: The help page actually shows you how to grab a screenshot from IE.
There isn't anything in the PHP library to do this - you're looking at setting up an external application (with a queue) to take images, although you can of course use PHP to add items to the queue.
There are a couple of Windows functions in GD that takes screen shots of the computer (webserver - not the client) so perhaps you could write a script in PHP to do this.
Edit: Was thinking of these: imagegrabscreen and imagegrabwindow. I'm not sure they will do what you want however (even in full screen mode Firefox has ablue bar at the top of the screen - not sure about other browsers). However, Pierre has something on these functions if you're interested.
I'd suggest writing an application in another language (I assume .NET has something) to do this for you.
Edit: This page tells you how to do it in C#
There's not much PHP would do for you in this situation. You'd need a complete (X)HTML rendering engine with CSS-support, possibly also with JavaScript support.
That, or use some kind of kinky script that would launch a real browser, and take a screenshot out of that. Either way, PHP is probably not the right tool for the operational part.
There's a Firefox extension that converts the webpage you're viewing to an image:
http://www.screengrab.org/
http://addons.mozilla.org/en-US/firefox/addon/1146
If you're willing to get creative, it might be possible to access this problematically.
Thanks to all.
I found a pseudo-solution, (using dcom + imagegrabscreen + wamp).
I need to resize the final.png with gd, because the png is equal to resolution of client (in my home, is a picture of 1650*1280).
Whe I end this, I will post a .zip file to dowload
Thanks again
(But if anyone have a better idea, I am happy to see that)
PS: Sorry for my english

Categories