The scenario is: when a user upload a image, we do image resizing on the server, but instead of waiting for this job done, I want it to response to the user immediately. if there is a thread available, I would properly just use thread to do this task, but as far as I know , there is no thread in php, so how can I achieve this goal? Thanks for ideas and suggestions.
Answers
The argument of the Imagick
constructor is to load a local image file. To load a remote image file, you should instantiate an Imagick
object without arguments and either:
- download the image content and pass it to the
readImageBlob
method, or fopen
the URL and pass it to thereadImageFile
method.
For example:
// assuming $image is an URL or path to a local file
$handle = fopen($image, 'rb');
$im2 = new Imagick();
$im2->readImageFile($handle);
$im2->setImageFormat("tiff");
$im2->setImageColorSpace(5);
$im2->writeImage("test.tiff");
fclose($handle);
$im2->destroy();
Given all your data downloaded to my computer, I can convert it to png using ImageMagick 6.9.10.82 Q16 Mac OSX Sierra that calls Inkscape 0.92.4 as the SVG renderer.
convert right.inside.svg x.png
You have not shown the correct result. So I do not know if this is correct or not. But it does appear to be correct given the images in the assets folder.
However, the mask and other image needs to be accessible from whomever is trying to view the svg file. So either the data needs to be downloaded or perhaps you need to provide the URL to those files on some server that has the svg file.
Use this tag:
<meta http-equiv="X-UA-Compatible" content="IE=8" />
- This CodeProject comment does it by simulating key presses
- Vista+ has API to do this, with ShowDeskBand and HideDeskBand
Edit: This code can now Add a deskband object (from Pinvoke.net, and these two MSDN forum questions):
[ComImport] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [Guid("4CF504B0-DE96-11D0-8B3F-00A0C911E8E5")] public interface IBandSite { [PreserveSig] uint AddBand([In, MarshalAs(UnmanagedType.IUnknown)] Object pUnkSite); [PreserveSig] void RemoveBand(uint dwBandID); } private uint AddDeskbandToTray(Guid Deskband) { Guid IUnknown = new Guid("{00000000-0000-0000-C000-000000000046}"); Guid ITrayBand = new Guid("{F60AD0A0-E5E1-45cb-B51A-E15B9F8B2934}"); Type TrayBandSiteService = Type.GetTypeFromCLSID(ITrayBand, true); IBandSite BandSite = Activator.CreateInstance(TrayBandSiteService) as IBandSite; object DeskbandObject = CoCreateInstance(Deskband, null, CLSCTX.CLSCTX_INPROC_SERVER, IUnknown); return BandSite.AddBand(DeskbandObject); }
And, an example use:
Guid address_toolbar_guid = new Guid("{01E04581-4EEE-11D0-BFE9-00AA005B4383}");
uint band_id = AddDeskbandToTray(address_toolbar_guid);
It would make sense that a similar call to RemoveBand would also do the trick, but as of yet, I can't get that code to work. Another issue: the added deskband closes when the application that added it closes.
Either fork the process (ugly and unreliable) or use a JobQueue, like Gearman.