Press Ctrl / CMD + C to copy this to your clipboard.
Copied to clipboard
Flag this post as spam?
This post will be reported to the moderators as potential spam to be looked at
Topic author was deleted
Apr 24, 2015 @ 19:47
Image Cropper/Image Processor Crops
First off, thx for the package, it's great.
It seems that image processor isn't working with the images I have stored on Azure.
For example, this won't work: blah.blob.core.windows.net/mendozaappmedia/1017/somepicture.png?anchor=center&mode=crop&width=1400&height=550&rnd=130743701050000000
Guessing it's because the image processor handler can only run for things hosted locally.
Hmmm... I don't know the ins-and-outs of the GetCropUrl API so I don't know for certain what overloads are available.
You definitely need to prefix your urls so that the application can intercept the request.
My steps would be.
Update to the latest ImageProcessor, ImageProcessor.Web and ensure you have ImageProcessor.Web.Config installed.
Add the domain for the source images to the whitelist in security config - (config/imageprocessor/security.config) docs example.
Install the AzureBlobCache plugin since there is no point caching your images in the file system if you are using blob storage.
Configure the cache provider in cache.config - (config/imageprocessor/security.config) docs example. - If you want to use a single blob container for the
source and cached images you can copy the details from the cache account to the source account for better image identification.
Make sure all blob containers are public and you have a CDN set up.
Enjoy a nice cup of tea and celebrate a job well-done.
If there is no built-in helper for getting the crop url with the remote prefix I would heartily recommend writing an extension method to manipulate the url to match what you need.
Looks like it's all good. I was doing some url intercepting for RTE images so I fixed that and it all works. If anyone follows along, the core works as expected if you add those two package updates.
You get the cropped image from azure blob cache container. Actually it took me while to get all config settings right. So it might be helpfull to put my examples here:
However when I enable my AzureBlobStorage, I'm getting 404's on the frontend despite the files showing up in the cache when saving in the backend.
When I switch back to DiskCache (in the cache.config), everything works fine.
I'm not sure how the plumbing is setup for the CDN (if that's a factor), but I created a CDN url as well b/c I was getting 500 errors when I didn't have one configured.
But crops and everything work fine, just can't get the cache to work.
Secondly, it would be great if I could disable Azure caching when dev'ving locally. Is there a way to indicate which cache to use in which environment? Typically I rely on the transforms for that.
Hi Kevin, did you wait about 60 minutes after creating the CDN? It takes up to this time to be available.
Currently it is not poosible to use the Azure Development Storage Emulator (Azure SDK) with the ImageProccessor.Web Azure cache plugin. I already send James a pull request for this - not feedback yet...
I am not sure how we can handle different environments as the UmbracoAzureBlobStorageProvider config is done in the /config/FileSystemProviders.config.
Dirk, I've added some feedback to your pull request, a few tweaks and I think we can do something cool.
As far as switching the cache depending on the environment?.... Eeeesh... I really don't know, I would have to ensure that each IImageCache can exist with or without that behaviour in order to prevent breaking everyone's sites.
Can you do config transforms for files other than the web.config?
However when I try to enable the cache store in Azure, every image throws a 500 on the frontend with this error:
An unhandled exception occurred System.ArgumentNullException: Value cannot be null. Parameter name: key at System.Collections.Concurrent.ConcurrentDictionary`2.TryGetValue(TKey key, TValue& value) at ImageProcessor.Web.Extensions.TypeInitializationExtensions.InstanceCreationFactory`3.CacheInstanceCreationMethodIfRequired(Type type) at ImageProcessor.Web.Extensions.TypeInitializationExtensions.InstanceCreationFactory`3.CreateInstanceOf(Type type, TArg1 arg1, TArg2 arg2, TArg3 arg3) at ImageProcessor.Web.Extensions.TypeInitializationExtensions.GetInstance[TArg1,TArg2,TArg3](Type type, TArg1 argument1, TArg2 argument2, TArg3 argument3) at ImageProcessor.Web.HttpModules.ImageProcessingModule.<ProcessImageAsync>d__10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar) at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Disabling the Azure cache makes it all work.
Any idea what the 'key' property is?
I'm configured just like Dirk (cache.config) except the containers and credentials are what they should be for my setup.
In this scenario ImageProcessor.Web is doing a 302 redirect to the CDN on caching so that subsequent requests come from there.
It is possible though to set up ImageProcessor.Web to return as stream in the scenario where requests to the CDN redirect to an endpoint when an image is not found.
There's some configuration information here and discussion on the scenario on Github.
but if I open my browser I got my image : intranet.blob.core.windows.net/media/1028/fred.jpg?width=200&height=200¢er=0,509677419354839,0,63768115942029&mode=crop
The remote server returned an error: (404) Not Found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The remote server returned an error: (404) Not Found.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[WebException: The remote server returned an error: (404) Not Found.]
System.Net.HttpWebRequest.GetResponse() +1465
ImageProcessor.Web.Plugins.AzureBlobCache.AzureBlobCache.RewritePath(HttpContext context) +484
ImageProcessor.Web.HttpModules.
Not sure how this differs from everyone else's set up, apart from the fact that our CDN points to http://[BlobStorage]/cache, rather than the root. Could this be an issue?
Topic author was deleted
Image Cropper/Image Processor Crops
First off, thx for the package, it's great.
It seems that image processor isn't working with the images I have stored on Azure.
For example, this won't work: blah.blob.core.windows.net/mendozaappmedia/1017/somepicture.png?anchor=center&mode=crop&width=1400&height=550&rnd=130743701050000000
Guessing it's because the image processor handler can only run for things hosted locally.
Have you run into this before?
I'll also follow up with James South.
Are you prefixing your image requests to tell ImageProcessor that you are pulling a remote file?
e.g.
Note no
http://
in the relative urlAlso, for your cache storage are you using the Azure Blob Cache plugin to cache your images?
http://imageprocessor.org/imageprocessor-web/plugins/azure-blob-cache/
Comment author was deleted
I'm calling images like so:
@image.GetCropUrl(height: 550, width: 1400)
Do I simply need to prefix something somewhere?
Do I install that package first? :)
THx btw.
No worries :)
Hmmm... I don't know the ins-and-outs of the
GetCropUrl
API so I don't know for certain what overloads are available.You definitely need to prefix your urls so that the application can intercept the request.
My steps would be.
If there is no built-in helper for getting the crop url with the remote prefix I would heartily recommend writing an extension method to manipulate the url to match what you need.
Hopefully that should do it.
Comment author was deleted
Super, I think that's the info I was looking for. I'll report back tomorrow.
Cheers!
Comment author was deleted
Well I can give an early update.
Installing the two packages and configuring the whitelist immediately fixed the GetCropUrl().
Now I just have the issue that images embedded in the RTE are not prefixed (I suppose).
I'll look into that more.
Thanks again.
Comment author was deleted
Looks like it's all good. I was doing some url intercepting for RTE images so I fixed that and it all works. If anyone follows along, the core works as expected if you add those two package updates.
Thanks James!
Comment author was deleted
Final update for the day. I think the core 'working just fine' was a false positive.
The false positive is due to the fact the images were still in /media on the local file system.
So come Monday I will be working to create extensions b/c it appears image processor is working fine given the right url.
Glad you've made some progress. Shout me if any issues pop up. :)
Hi Kevin & James,
I was curious about this issue and figure out what might be missing:
The ImageProcessor plugin AzureBlobCache does not create the configured blob container automatically. Thus you have to create it manually.
At least after all config settings in place and doing a little replacing on the GetCropUrl like:
@typedMedia.GetCropUrl("myCropName").Replace("://", "://mydomain/remote.axd/")
You get the cropped image from azure blob cache container.
Actually it took me while to get all config settings right. So it might be helpfull to put my examples here:
/config/imageprocessor/cache.config
</caching>
/config/imageprocessor/cache.config
</security>
/config/FileSystemProviders.config
</FileSystemProviders>
Yours,
Dirk
Comment author was deleted
@Dirk, thanks for that. I'll give that a try on Monday. Without a working Image Processor cache, it negates the power of storing stuff on Azure.
#h5yr
Comment author was deleted
Ok fellas. Working pretty well.
However when I enable my AzureBlobStorage, I'm getting 404's on the frontend despite the files showing up in the cache when saving in the backend.
When I switch back to DiskCache (in the cache.config), everything works fine.
I'm not sure how the plumbing is setup for the CDN (if that's a factor), but I created a CDN url as well b/c I was getting 500 errors when I didn't have one configured.
But crops and everything work fine, just can't get the cache to work.
Secondly, it would be great if I could disable Azure caching when dev'ving locally. Is there a way to indicate which cache to use in which environment? Typically I rely on the transforms for that.
Hi Kevin, did you wait about 60 minutes after creating the CDN? It takes up to this time to be available.
Currently it is not poosible to use the Azure Development Storage Emulator (Azure SDK) with the ImageProccessor.Web Azure cache plugin.
I already send James a pull request for this - not feedback yet...
I am not sure how we can handle different environments as the UmbracoAzureBlobStorageProvider config is done in the /config/FileSystemProviders.config.
Any ideas?
Dirk
Comment author was deleted
Thx Dirk. I haven't waited long enough :)
RE: the dev. Perhaps a web.config appSetting could indicate which cache to use? That way a transform of the web.config would handle the env switch.
i.e.
<add key="imageprocessor.cache:currentCache" value="DiskCache"/>
Ok, probably James could do that for the ImageProcessor plugin. We have to await his response...
However, I dont see a way for the UmbracoAzureBlobStorageProvider as this controled by Umbraco.
At least both packages sould to be in sync.
Hi Kevin,
I found a solution to toggle Azure Cloud Storage and WAStorageEmulator by an optional appSetting:
<add key="AzureBlobFileSystem.UseWAStorageEmulator" value="true" />
This is for UmbracoAzureBlobStorageProvider version 1.0.10.4 or higher.
Dirk
Hi guys, sorry for the slow reply, super busy!
Dirk, I've added some feedback to your pull request, a few tweaks and I think we can do something cool.
As far as switching the cache depending on the environment?.... Eeeesh... I really don't know, I would have to ensure that each
IImageCache
can exist with or without that behaviour in order to prevent breaking everyone's sites.Can you do config transforms for files other than the web.config?
Comment author was deleted
AFAIK you can only do transformation in the web.config.
All my configuration, including caching is stored outside the web.config but their location is dictated by value in the web.config.
You put a transform in your web.config pointing the custom section to a different config files in the
/config/imageprocessor/folder
.That should allow it.
Comment author was deleted
PERFECT :)
I'm already doing that for Dirk's file storage provider. I just didn't notice that it added the configSource stuff to the bottom of my web.config.
Brilliant, problem solved +1
Thank you :)
:) I can't believe it took me so long to realise.
You should post a sample of the transforms here so I can steal them (I always mess them up).
Comment author was deleted
Sooooo close to getting the cache working...
However when I try to enable the cache store in Azure, every image throws a 500 on the frontend with this error:
An unhandled exception occurred System.ArgumentNullException: Value cannot be null. Parameter name: key at System.Collections.Concurrent.ConcurrentDictionary`2.TryGetValue(TKey key, TValue& value) at ImageProcessor.Web.Extensions.TypeInitializationExtensions.InstanceCreationFactory`3.CacheInstanceCreationMethodIfRequired(Type type) at ImageProcessor.Web.Extensions.TypeInitializationExtensions.InstanceCreationFactory`3.CreateInstanceOf(Type type, TArg1 arg1, TArg2 arg2, TArg3 arg3) at ImageProcessor.Web.Extensions.TypeInitializationExtensions.GetInstance[TArg1,TArg2,TArg3](Type type, TArg1 argument1, TArg2 argument2, TArg3 argument3) at ImageProcessor.Web.HttpModules.ImageProcessingModule.<ProcessImageAsync>d__10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar) at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Disabling the Azure cache makes it all work.
Any idea what the 'key' property is?
I'm configured just like Dirk (cache.config) except the containers and credentials are what they should be for my setup.
Comment author was deleted
Ok nm that ==^ I had a copy/paste fail.
Works now!
Ok on to the transform.
Comment author was deleted
Ok, 100% complete.
As promised, here are the transforms and how i setup my cache config. I removed my acct details:
Hi all,
I have just added a useful solution for local development with Windows Azure Storage Emulator to project documentation.
:) Dirk
GO TEAM AWESOME! :)
In this scenario what is the CDN doing as far as I can see the image urls on the site are referring to the site rather than the CDN?
Maybe be I am misunderstanding it and need to set the CDN origin to be http://yoursite.com/remote.axd/blah.blob.core.windows.net/mendozaappmedia/ ?
Hi John,
In this scenario ImageProcessor.Web is doing a 302 redirect to the CDN on caching so that subsequent requests come from there.
It is possible though to set up ImageProcessor.Web to return as stream in the scenario where requests to the CDN redirect to an endpoint when an image is not found.
There's some configuration information here and discussion on the scenario on Github.
Cheers
James
Hi
Thank you for your reply, it had been working until I looked in a little deeper. I am finding the 302 direct is taking a very long time.
Is there a reason that this would be happening. Is it a latency issue with the blob storage or something else?
Hi John,
Sorry, didn't spot this. I imagine it would be latency. I've not noticed an issue myself testing.
Hi,
I follow this thread for my setup,
I got an 404 not found
http://localhost:49909/remote.axd/intranet.blob.core.windows.net/media/1028/fred.jpg?width=200&height=200¢er=0,509677419354839,0,63768115942029&mode=crop
but if I open my browser I got my image : intranet.blob.core.windows.net/media/1028/fred.jpg?width=200&height=200¢er=0,509677419354839,0,63768115942029&mode=crop
The remote server returned an error: (404) Not Found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The remote server returned an error: (404) Not Found.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[WebException: The remote server returned an error: (404) Not Found.] System.Net.HttpWebRequest.GetResponse() +1465 ImageProcessor.Web.Plugins.AzureBlobCache.AzureBlobCache.RewritePath(HttpContext context) +484 ImageProcessor.Web.HttpModules.
Do you have an idea ?
Hi Oliver,
I'd have to see how you have set up your configuration files.
Could you possible post that, without the security keys obviously ;) so I could have a look?
Cheers
James
Hi,
I think I was Impatient .. That works like charm !
Thx anyway !
Great to hear! :)
Hi Olivier. I'm getting the same error message as you, but patience is not fixing it. Did you do anything to resolve your issue apart from wait?
Hi,
I would like to notice that I have the same issue as John. I am finding the 302 direct is taking a very long time.
Hi guys. I'm having issues setting this up. I'm getting a 404 for the cached images.
Not sure how this differs from everyone else's set up, apart from the fact that our CDN points to http://[BlobStorage]/cache, rather than the root. Could this be an issue?
Hi,
here my config:
Note: StreamCachedImage are optional. It's because if I set to false the redirect take too long....
Thanks for the reply Olivier. Unfortunately I've tried a set up like that and I still had no joy.
Do you know where your CDN points to? Is it source blob root, source blob container, or cached container?
Does it matter?
Yes, It's public blob container
Thanks Olivier. I better confirm the containers are public...
Finally got it working. For anyone who's interested, the CDN's origin must be the root storage account, no container.
is working on a reply...