Showing posts with label Image Carousel. Show all posts
Showing posts with label Image Carousel. Show all posts

Sunday, September 2, 2012

Wikimedia Commons queries to get image data

I am developing application to get images from Wikimedia Commons which is a big repository of excellent images. The query API is not well documented. I researched and came up with the following queries to get the file locations of images.

Suppose I want to get the images in the Category Flags of United States, I will do the following:

http://commons.wikimedia.org/w/api.php?format=xml&action=query&list=categorymembers&cmlimit=10&cmtitle=Category:benthos

which produces the following XML output for the first 10 items.

<?xml version="1.0"?>
-<api>-<query>-<categorymembers><cm title="Category:Porifera" ns="14" pageid="13371"/><cm title="Category:Riftia pachyptila" ns="14" pageid="8805563"/><cm title="File:1991 benthos-achtern02 hg.jpg" ns="6" pageid="3321991"/><cm title="File:Abra alba.jpg" ns="6" pageid="333239"/><cm title="File:Ammonia tepida.jpg" ns="6" pageid="706636"/><cm title="File:Aonides paucibranchiata.jpg" ns="6" pageid="396315"/><cm title="File:Aphrodita aculeata (Sea mouse).jpg" ns="6" pageid="3610614"/><cm title="File:Aphrodita aculeata.jpg" ns="6" pageid="1525478"/><cm title="File:Arenicole système.jpg" ns="6" pageid="4258545"/><cm title="File:Asterias rubens.jpg" ns="6" pageid="364648"/></categorymembers></query>-<query-continue><categorymembers cmcontinue="file|42454e5448494320464f52414d494e4946455241532e4a5047|2080936"/></query-continue></api>


to  get an image you have to use the



http://commons.wikimedia.org/wiki/File:Aonides%20paucibranchiata.jpg will take you to the Aonides paucibranchiata image!



if you query

http://commons.wikimedia.org/w/api.php?format=xml&action=query&list=categorymembers&cmlimit=10&cmtitle=Category:benthos&cmcontinue=file|42454e5448494320464f52414d494e4946455241532e4a5047|2080936



you get the following output  which are the next 10 items, and so on



<?xml version="1.0"?>
-<api>-<query>-<categorymembers><cm title="File:Benthic foraminiferas.jpg" ns="6" pageid="2080936"/><cm title="File:Benthic GLERL 1.jpg" ns="6" pageid="2143998"/><cm title="File:Bentos kasarek.jpg" ns="6" pageid="16992357"/><cm title="File:Borstenwurmer des Meeres.png" ns="6" pageid="5229875"/><cm title="File:Branchiostoma lanceolatum.jpg" ns="6" pageid="5712836"/><cm title="File:Capitella capitata.jpg" ns="6" pageid="398359"/><cm title="File:Cirratulus cirratus.jpg" ns="6" pageid="398775"/><cm title="File:Crabmuss 600.jpg" ns="6" pageid="292191"/><cm title="File:Crangon crangon (dorsal).jpg" ns="6" pageid="10320338"/><cm title="File:Crangon crangon.jpg" ns="6" pageid="470098"/></categorymembers></query>-<query-continue><categorymembers cmcontinue="file|4352494252494e4f50534953204645524e414c44492e4a5047|3307271"/></query-continue></api>


Other useful formats



format=json



format=jsonfm produces a html output of json format.



Reference




  1. API reference


  2. API:Main page


  3. API:Tutorial

Friday, November 26, 2010

Observable collections and photo slide show in Silverlight

Recently I did a  nice photo collection slide show in Silverlight. It is really simple. Use observable collection.

I had a list of thumbnail URLs in a list generated from a web service. The image list had 10 image urls in it.

I created a second list with 3 image urls as an observable collection in the class declaration.

public ObservableCollection<String>  Thumb_list { get; set; }

Then I had XAML for holding 3 images and had a left and right arrow buttons on both sides of the images.

When they were clicked the observable collections image list was again populated with new images offset by one from the original image list. The code is given below.  Of course, you have to make sure that you are not over running the indexes.

  private void Click_Left_Arrow(object sender, RoutedEventArgs e)
{
var thumblistdetails = ((Button)sender).DataContext as client_data;
if (thumblistdetails.image_index > 0)
{
thumblistdetails. Thumb_list[0] = List_silver_data[thumblistdetails.row_index].Thumb_list[thumblistdetails.image_index - 1];
thumblistdetails. Thumb_list[1] = List _silver_data[thumblistdetails.row_index].Thumb_list[thumblistdetails.image_index];
thumblistdetails Thumb_list[2] = List_silver_data[thumblistdetails.row_index]. Thumb_list[thumblistdetails.image_index + 1];
thumblistdetails.image_index--;
}
}



This was a cool application. Shortly I will write a code project article on this.

Monday, April 26, 2010

Sivlerlight Carousel and Phot Albums for photo display

I was looking for a way to display pictures in a carousel or a photo album.
Nikhil has an interesting blog which is done in Silverlight 1.0
http://www.nikhilk.net/SilverlightCarousel3.aspx

Terence Tsang has a couple of them in his blog Shinedraw in which he has compared flash with silverlight:
http://www.shinedraw.com/animation-effect/flash-vs-silverlight-image-carousel/
http://www.shinedraw.com/3d-illusion/flash-vs-silverlight-image-advance-carousel/

Vectorform also has an interesting carousel done in silverlight in Javascript

http://www.vectorform.com/silverlight/blog/index.php/2009/01/23/image-carousel-silverlight-20/

Silverlight Slide Show by Vbrocks is a great one but in VB.
http://www.codeproject.com/KB/silverlight/Silverlight3_Slideshow.aspx

Codeplex has a terriffic slideshow based on Silverlight and done in C#
http://slideshow.codeplex.com/

Phluffyphotos has an example which is supposed to work with WindowsAzure.
But I could not make it work.
http://phluffyfotos.codeplex.com/