thumbor // url syntax to crop and apply filter at the same time - thumbnails

For the ones that uses it, if it is ever possible
Looking though the docs, can't find a clue about building an url that would crop the image and apply a filter at the same time
Thanks for the help

Sure thing, the syntax would be like this:
http://<your_thumbor_server>/unsafe/<crop>/filters:<some_filter>/<image_source_url>
Which might look something like this:
http://thumborhost.com/unsafe/200x0:600x800/filters:format(webp)/http://imagehost.com/path/to/source.jpg
The full url syntax as stated by the Thumbor docs is:
http://thumbor-server/hmac/trim/AxB:CxD/fit-in/-Ex-F/HALIGN/VALIGN/smart/filters:FILTERNAME(ARGUMENT):FILTERNAME(ARGUMENT)/image-uri
Docs: http://thumbor.readthedocs.org/en/latest/usage.html

Related

google adslot syntax - is there a way to not specify a criteria?

I am trying to introduce interstitial adverts for a web project but I am confused about how to use an existing adslot without defining a criteria for that (or if it is even possible?)
From the documentation here:
https://developers.google.com/publisher-tag/reference
https://developers.google.com/publisher-tag/guides/key-value-targeting
There are some examples that show a chosen category of advert to be shown, for example:
googletag.defineSlot('/1234567/sports', [728, 90], 'div-1');
or
googletag.defineOutOfPageSlot('/6355419/Travel/Europe/France/Paris',
googletag.enums.OutOfPageFormat.INTERSTITIAL);
when I try to use the sample code with my account ID and the ad-unit name, it does not work. I don't want to define cateogries at this stage, I would prefer that it is done automatically.
For example
interstitialSlot = googletag.defineOutOfPageSlot('/26*****997/auto',
googletag.enums.OutOfPageFormat.INTERSTITIAL);
or
interstitialSlot = googletag.defineOutOfPageSlot('/26*****997/interstitial-unit-name',
googletag.enums.OutOfPageFormat.INTERSTITIAL);
but neither of these formats are accepted and the documentation seems to be somewhat lacking in other examples.
Any help appreciated.
interstitialSlot = googletag.defineOutOfPageSlot('/26*****997/auto',
googletag.enums.OutOfPageFormat.INTERSTITIAL);
Use this and wait 24 hours only

How do I pass xquery through eXist-db's REST api?

I understand how to use Xpath
http://localhost:8080/exist/rest/db/movies?_query=//movie[title=%22Spider-Man%22]/node()
But how to pass an xquery query? I keep reading everywhere that the REST api is for both xpath and xquery but I can't get my query to work. Here is what I'm trying to pass as an example (I've tested this in the xquery sandbox and it works):
for $movie in doc("movies/movies.xml")/movies/movie[year > 2002]
return <movie> { ($movie/title, $movie/year) } </movie>
How do I pass this in a URL? I dont really know where to start so I've tried just pasting the query above as the GET param, similar to the xpath query. So the url I pass is
http://localhost:8080/exist/rest/db/movies/?_query=for%20$movie%20in%20doc(%22movies/movies.xml%22)/movies/movie[year%20%3E%202002]%20return%20%3Cmovie%3E%20{%20($movie/title,%20$movie/year)%20}%20%3C/movie%3E
The page I get back is this
Am I going about this totally the wrong way? "movies" is a collection in my db.
It looks like your query was successfully executed. The <exist:result/> element looks quite correct, but it simply didn't find any movies which fit your filter criteria. It might also be a namespace issue. You should try your query locally to see if it returns something.
Your <script id="tinyhippos-injected"/> element is rather weird, as I did not expect tiny hippos here. However, this seems to be due to some Chrome extension you use.
Also, if your XQuery is a bit longer a URL paramter will not do and the encoding is difficult to read and maintain anyways. You might want to take a look at the eXist documentation about how to submit a POST request with an XQuery.

How to Convert IPicture to Image - .NET 4.5 TagLib Sharp

I am wanting to display the album artwork of a song (accessed via the taglib-sharp library) within a Windows Forms picture box. The problem I'm running into is that the taglib-library returns an image of type TagLib.IPicture whereas the picture box requires an object of type System.Drawing.Image.
I have scoured the internet for many hours now, looking for a way to convert from an IPicture to Image, but to no avail. The best lead I have is this: http://msdn.microsoft.com/en-us/library/system.windows.forms.axhost.getpicturefromipicture.aspx, but I have yet to see a successful example of how to implement this.
Any help as to how to convert between these two types would be much appreciated. Note: IPicture is not analogous to IPictureDisp in this case.
I've done the opposite before - turning an existing .jpg into an IPicture for embedding in an .mp3 file. I just tried reversing that operation and, after tweaking and testing, came up with this:
TagLib.File tagFile = TagLib.File.Create(mp3FilePath);
MemoryStream ms = new MemoryStream(tagFile.Tag.Pictures[0].Data.Data);
System.Drawing.Image image = System.Drawing.Image.FromStream(ms);
Thanks for the question - I already know how I'm going to use this myself!
Update: Here's the other way (.jpg to IPicture that I've done before):
tagFile.Tag.Pictures = new TagLib.IPicture[]
{
new TagLib.Picture(new TagLib.ByteVector((byte[])new System.Drawing.ImageConverter().ConvertTo(System.Drawing.Image.FromFile(jpgFilePath), typeof(byte[]))))
};

phpThumb is not setting parameter – fltr[] usm

I am using Brett's Mr. PHP thumb caching script along with phpThumb to create my thumbs. It works extremely well, except for one thing... I cannot get it to set and process the UnSharpMask filter. The relevant part of the script looks like this:
// generate the thumbnail
require('../phpthumb/phpthumb.class.php');
$phpThumb = new phpThumb();
$phpThumb->setSourceFilename($image);
$phpThumb->setParameter('w',$width);
$phpThumb->setParameter('h',$height);
$phpThumb->setParameter('q','95'); // set the quality to 95%
$phpThumb->setParameter('fltr[]','usm|80|0.5|3'); // <--- THIS SHOULD SET THE USM FILTER
$phpThumb->setParameter('f',substr($thumb,-3,3)); // set the output file format
if (!$phpThumb->GenerateThumbnail()) {
error('cannot generate thumbnail');
}
I'm guessing there's a problem with my syntax, since the fltr[] parameter requires brackets. I have tried escaping the brackets like so: 'fltr[]' but that didn't work either.
I've used several other possible parameters with good success (zoom cropping, max height, max width, etc...) Everything seems to work except the filters (including usm - UnSharpMask).
I don't get any errors. It spits out thumbs all day long. They're just not sharpened.
For reference, here's the official phpThumb readme file that discusses all the possible settings and filters.
Thanks for looking.
Well after much trial, error, and aggravation, I finally discovered the solution buried in one of the demo files that come with phpThumb.
It's a matter of removing the brackets all together. Basically changing this line:
$phpThumb->setParameter('fltr[]','usm|80|0.5|3');
to this:
$phpThumb->setParameter('fltr','usm|80|0.5|3');
After that, it's only a matter of tweaking the settings to get the desired amount of sharpness.

Padrino + MongoMapper/Joint Troubles

I'm using MongoMapper with Joint on Padrino, and trying to get the
upload working. However, I keep getting thrown a NoMethodError
"undefined method 'path' for #<Hash:0xa6fbdf0>". It seems like it
can't see the path, but the parameters are okay. What is the problem
here?
Gist with the code: https://gist.github.com/1323998
I was able to get it to not error, but when I go to find the file with mongofiles, I can't find. The same goes for rack/grid-fs. Where is Joint saving to, and is it saving at all?
See my comments above:
Here's my thought on what you need to do, I think you need to modify the params so that params[:background][:file] is the tempfile object, like so:
params[:background][:file] = params[:background][:file][:tempfile]
background = Background.create(params[:background])
I'm not 100% sure on this, but if this doen't work I could setup a quick Padrino app and test.