From ea6addb4c83cf53799c2dcb780291677a2cb6086 Mon Sep 17 00:00:00 2001
From: Antoine Vandecreme <ant.vand@gmail.com>
Date: Tue, 26 Jan 2016 18:02:11 -0500
Subject: [PATCH 1/2] Add Viewer.addSimpleImage method. Fix #818

---
 src/viewer.js               | 25 +++++++++++++++++++++++++
 test/modules/multi-image.js | 18 ++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/src/viewer.js b/src/viewer.js
index 16d5cfa1..30900ba7 100644
--- a/src/viewer.js
+++ b/src/viewer.js
@@ -1393,6 +1393,31 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
         } );
     },
 
+    /**
+     * Add a simple image to the viewer.
+     * The options are the same than {@link OpenSeadragon.Viewer#addTiledImage}
+     * except for options.tileSource which is replaced by options.url.
+     * @function
+     * @param {Object} options - See {@link OpenSeadragon.Viewer#addTiledImage}
+     * for all the options
+     * @param {String} options.url - The URL of the image to add.
+     * @fires OpenSeadragon.World.event:add-item
+     * @fires OpenSeadragon.Viewer.event:add-item-failed
+     */
+    addSimpleImage: function(options) {
+        $.console.assert(options, "[Viewer.addSimpleImage] options is required");
+        $.console.assert(options.url, "[Viewer.addSimpleImage] options.url is required");
+
+        var opts = $.extend({}, options, {
+            tileSource: {
+                type: 'image',
+                url:  options.url
+            }
+        });
+        delete opts.url;
+        this.addTiledImage(opts);
+    },
+
     // deprecated
     addLayer: function( options ) {
         var _this = this;
diff --git a/test/modules/multi-image.js b/test/modules/multi-image.js
index 5d4b21bd..bf1b03ae 100644
--- a/test/modules/multi-image.js
+++ b/test/modules/multi-image.js
@@ -189,4 +189,22 @@
         ]);
     });
 
+    asyncTest('Viewer.addSimpleImage', function() {
+        viewer.addHandler("open", function openHandler() {
+            viewer.removeHandler("open", openHandler);
+
+            viewer.world.addHandler('add-item', function itemAdded(event) {
+                viewer.world.removeHandler('add-item', itemAdded);
+                equal(event.item.opacity, 0.5, 'Opacity option not set using addSimpleImage');
+                start();
+            });
+
+            viewer.addSimpleImage({
+                url: '/test/data/A.png',
+                opacity: 0.5
+            });
+        });
+        viewer.open('/test/data/testpattern.dzi');
+    });
+
 })();

From 9dbcd28a5a9eda5edafbf4a410ceba2d2bfc7e7e Mon Sep 17 00:00:00 2001
From: Antoine Vandecreme <ant.vand@gmail.com>
Date: Wed, 27 Jan 2016 21:49:05 -0500
Subject: [PATCH 2/2] English fixes.

---
 src/viewer.js               | 2 +-
 test/modules/multi-image.js | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/viewer.js b/src/viewer.js
index 30900ba7..ca77de89 100644
--- a/src/viewer.js
+++ b/src/viewer.js
@@ -1395,7 +1395,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
 
     /**
      * Add a simple image to the viewer.
-     * The options are the same than {@link OpenSeadragon.Viewer#addTiledImage}
+     * The options are the same as the ones in {@link OpenSeadragon.Viewer#addTiledImage}
      * except for options.tileSource which is replaced by options.url.
      * @function
      * @param {Object} options - See {@link OpenSeadragon.Viewer#addTiledImage}
diff --git a/test/modules/multi-image.js b/test/modules/multi-image.js
index bf1b03ae..f3710429 100644
--- a/test/modules/multi-image.js
+++ b/test/modules/multi-image.js
@@ -195,7 +195,8 @@
 
             viewer.world.addHandler('add-item', function itemAdded(event) {
                 viewer.world.removeHandler('add-item', itemAdded);
-                equal(event.item.opacity, 0.5, 'Opacity option not set using addSimpleImage');
+                equal(event.item.opacity, 0.5,
+                    'Opacity option should be set when using addSimpleImage');
                 start();
             });