How to set quality option on all images without using querystring? - imageresizer

Using https://imageresizing.net, how to set default quality so that all jpg and pngs are rendered with quality=90 without using querystring?
All photos should rendered like this:
https://azure.content.bloc.net/widget/200000184/363/2017/10/5/adam---eva-11.09.177001-copy.png?quality=90
without having to specify querystrings:
https://azure.content.bloc.net/widget/200000184/363/2017/10/5/adam---eva-11.09.177001-copy.png
Is it possible?

There is a DefaultSettings plugin for imageresizing, but as far as I know it only works for scaling.
Take a look at it here:
https://imageresizing.net/docs/v4/plugins/defaultsettings

I managed to do it in my custom plugin. I've created a custom virtual image provider, and I implemented the interface ISettingsModifier. Using it i managed to set the quality I wanted without using querystring.
public ResizeSettings Modify(ResizeSettings settings)
{
settings.Quality = 50;
return settings;
}

Related

Cannot read image file in appcelerator titanium

I have an image stored at /assets in my project folder and I am trying to read it using Ti.Filesystem.getFile(). The code prints the blob data in android but it prints undefined in iOS.
Following function is called on Button click event https://pastebin.com/QgqLQPyz
function readImg(e) {
var localPath = '/butterfly.jpg';
var cachedFilename = Ti.Utils.sha1(localPath) + localPath.substr(localPath.lastIndexOf('.'));
console.log("cachedFilename:---"+cachedFilename);
var cachedFile = Ti.Filesystem.getFile(Ti.Filesystem.applicationCacheDirectory, cachedFilename);
if(!cachedFile.exists()){
var blob = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, localPath).read();
console.log("-----------blob in not exists:"+JSON.stringify(blob));
}
}
When the same image path is set in ImageView it gets displayed so the issue is not with path . What am I missing here ? pls help. Thank you.
The best option so you don't have to do anything specific to the images at all (keep in mind, image manipulation is pretty heavy to do on runtime), is to use a module that was made for this purpose, av.imageview. This allows you to configure all kinds of content modes.
An option to get your code to work is to get the blob using the the getAsset method.
var blob = Ti.Filesystem.getAsset('/images/butterfly.jpg');
and then resize where you see fit. But I would advise you, if you do need to do this every time the app runs, then just resize once and store that resized image to be used after that. That way there will only be a single time the image needs resizing.

Change Cloudinary's images from private to public

There are 3 types of privacy for images uploaded to Cloudinary: http://support.cloudinary.com/entries/23183603-Does-Cloudinary-support-uploading-private-images-
How can I change a private image to be public?
It's on Cloudinary's road map to support changing between public and private file types.
Currently you can re-upload private images as public images (using Cloudinary URLs as input for upload).
Another option is to enable 'Strict Transformations' mode (From the Dashboard's settings page) and use our explicit API to create the required derived images without allowing the transformation globally. Here's the 'explicit' documentation (PHP):
http://cloudinary.com/documentation/php_image_upload#refresh_images
The accepted answer was in 2013.
We don’t need to re-upload the assets anymore for that!
So I am updating here for anyone who stumbles on this in more recent times.
To make an asset public to private or vice-versa on Cloudinary,
we can use the rename method of uploader as neatly suggested in this Cloudinary Support link.
In PHP:
$result = \Cloudinary\Uploader::rename($from_public_id, $to_public_id, $options = []);

Capture and save a photo in XAML/C# for a Windows store application

I'm trying to take and save a photo using a windows surface device.
I'm using the code below to take a photo and this work but I'd like to automatically create a directory on the device's local drive and save this photo there without any dialog prompts.
So the code I use to capture to photo is as follows:
CameraCaptureUI camera = new CameraCaptureUI();
StorageFile file = await camera.CaptureFileAsync(CameraCaptureUIMode.Photo);
if (file!=null)
{
using (IRandomAccessStream ras=await file.OpenAsync(FileAccessMode.Read))
{
BitmapImage source = new BitmapImage();
source.SetSource(ras);
imageBuildingPhoto.Source = source; // this is just an image control.
}
}
So after this I'd like to automatically save the photo to a new directory. e.g.
My Pictures\NewDirectory\Photo1.jpg
Anybody got any idea how I can do this?
This is a windows store application written using C#4.5 and XAML.
Thanks in advance
Use the CopyAsync method on the StorageFile object you get back (file). You can specify a directory and file name. If you need to create your own directory structure, you will need to enable access to the appropriate library in the Package Manifest then create it in code. You will then use the StorageFolder class and its CreateFolderAsync method to create folders.
http://aka.ms/30Days has some great resources for learning about scenarios like this. Might be worth checking out.
Your code will need to look to see if that folder exists and create it if it does not. Your app will need to declare the capability to access the user's Photos library in the app manifest, too.
To take a picture, your code is correct. I have a walkthrough in case you want to verify it against some other code: http://blog.jerrynixon.com/2012/10/walkthrough-capturing-photos-in-your.html
To interact with the file system, this can be tricky, but I have a longer write up on that if you want to reference it: http://blog.jerrynixon.com/2012/06/windows-8-how-to-read-files-in-winrt.html
The answer to your question is, yes you can. I have done it in my own apps. Now, it's just a matter of you implementing it in yours. You will find it to be pretty easy.

Better way to use Velocity's GenericTools in a Standalone app?

I want to use VelocityTool's GenericTools for some standard formatting in a standalone app. e.g. have something like this in my Velocity template to use the GenericTools' NumberTool formatter:
Total: $numberTool.format("#0.00", $totalPnL)
How do I associate the above "$numberTool" with the GenericTool NumberTool. Here's my Velocity code:
Velocity.init();
VelocityContext velocityContext = new VelocityContext();
Template template = Velocity.getTemplate("example.vm");
velocityContext.put("totalPnL", 100);
StringWriter sw = new StringWriter();
template.merge(velocityContext, sw);
Now I know I can do this to get it to work:
velocityContext.put("numberTool", new NumberTool());
But is that how I need to add all the GenericTools to my app? Manually and one at a time (e.g. another line for DateTool ... etc)? Isn't there a way to make all the GenericTools exposed to my template with out this? I know there's a "tools.xml" that comes with VelocityTools that has the GenericTools defined. Can I just add that to my app to expose all the tools? If so, how?
thanks,
David
http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/ToolManager.html
http://velocity.apache.org/tools/devel/standalone.html
The default tool configuration provides all the generic tools already. Though you can create a config if you want to configure those tools. There's even auto loading for configurations, or manual specification.
ToolManager tm = new ToolManager();
tm.setVelocityEngine(yourVelocityEngine);
Context context = tm.createContext();
it is at least the way I do it too.
I'll put for example
context.put("esc", new EscapeTool());
and in the template I simply use then
${esc.h}
to write a "#" in the code so that Velocity does not parse it as "velocity-script".
I think those helper tools are rather utils and only cover some basic signs. They are not intend to be a standard, you rather can include them on-demand.
I've build for example an abstract class that loads the context of velocity and puts the EscapeTool into the context all the time so that I do not have to add it everywhere.
Good luck with your project
Sebastian

Plugin.ImageResourceName doesn't seem to have any effect

It would be great if the Petrel Plugin Manager could display our custom bitmap for each of our plugins - however, the Plugin.ImageResourceName property doesn't seem to have any effect.
public override string ImageResourceName { get { return "Blueback.Toolbox.Plugin.Toolbox.png"; } }
The image is embedded correctly (according to the documentation and ILDisAsm) - but Plugin Manager insists on using the generic image instead. Are there undocumented requirements on dimensions or format? The code snippets in the documentation mention both bmp and png, without demonstrating that the property actually works.
I haven't been able to locate an actual running sample in the SDK (only Module samples) nor in the code sample downloads (several Plugins here, but they return null for the resource name).
Can anyone provide a working sample or the missing key?
The image provided via Plugin.ImageResourceName is displayed in the Petrel License Dialog, and you are right, it is not displayed in Plugin Manager as it always uses the generic image to represent plugins. We will consider changing it in Petrel 2013.1.