@@ -138,19 +138,24 @@ document.getElementById('file-input').onchange = function (e) {
138138
139139The second argument must be a ** callback** function, which is called when the
140140image has been loaded or an error occurred while loading the image. The callback
141- function is passed one argument, which is either a HTML ** img** element, a
141+ function is passed two arguments.
142+ The first is either an HTML ** img** element, a
142143[ canvas] ( https://developer.mozilla.org/en/HTML/Canvas ) element, or an
143- [ Event] ( https://developer.mozilla.org/en/DOM/event ) object of type ** error** :
144+ [ Event] ( https://developer.mozilla.org/en/DOM/event ) object of type ** error** .
145+ The second is on object with the original image dimensions as properties and
146+ potentially additional [ meta data] ( #meta-data-parsing ) :
144147
145148``` js
146149var imageUrl = " https://example.org/image.png" ;
147150loadImage (
148151 imageUrl,
149- function (img ) {
152+ function (img , data ) {
150153 if (img .type === " error" ) {
151- console .log (" Error loading image " + imageUrl);
154+ console .error (" Error loading image " + imageUrl);
152155 } else {
153156 document .body .appendChild (img);
157+ console .log (" Original image width: " , data .originalWidth );
158+ console .log (" Original image height: " , data .originalHeight );
154159 }
155160 },
156161 {maxWidth: 600 }
@@ -208,7 +213,7 @@ the image, which will be parsed automatically if the exif library is available.
208213Setting the ` orientation ` also enables the ` canvas ` option.
209214Setting ` orientation ` to ` true ` also enables the ` meta ` option.
210215* ** meta** : Automatically parses the image meta data if set to ` true ` .
211- The meta data is passed to the callback as second argument.
216+ The meta data is passed to the callback as part of the second argument.
212217If the file is given as URL and the browser supports the
213218[ fetch API] ( https://developer.mozilla.org/en/docs/Web/API/Fetch_API ) , fetches
214219the file as Blob to be able to parse the meta data.
@@ -244,9 +249,22 @@ element without any image size restrictions.
244249
245250## Meta data parsing
246251If the Load Image Meta extension is included, it is also possible to parse image
247- meta data.
248- The extension provides the method ** loadImage.parseMetaData** , which can be used
249- the following way:
252+ meta data automatically with the ` meta ` option:
253+
254+ ``` js
255+ loadImage (
256+ fileOrBlobOrUrl,
257+ function (img , data ) {
258+ console .log (" Original image head: " , data .imageHead );
259+ console .log (" Exif data: " , data .exif ); // requires exif extension
260+ console .log (" IPTC data: " , data .iptc ); // requires iptc extension
261+ },
262+ { meta: true }
263+ );
264+ ```
265+
266+ The extension also provides the method ** loadImage.parseMetaData** , which can be
267+ used the following way:
250268
251269``` js
252270loadImage .parseMetaData (
@@ -261,8 +279,8 @@ loadImage.parseMetaData(
261279 data .imageHead ,
262280 // Resized images always have a head size of 20 bytes,
263281 // including the JPEG marker and a minimal JFIF header:
264- loadImage .blobSlice .call (resizedImage , 20 )
265- ], {type: resizedImage .type });
282+ loadImage .blobSlice .call (resizedImageBlob , 20 )
283+ ], {type: resizedImageBlob .type });
266284 },
267285 {
268286 maxMetaDataSize: 262144 ,
@@ -271,15 +289,16 @@ loadImage.parseMetaData(
271289);
272290```
273291
274- The third argument is an options object which defines the maximum number of
275- bytes to parse for the image meta data, allows to disable the imageHead creation
276- and is also passed along to segment parsers registered via loadImage extensions,
277- e.g. the Exif and IPTC parsers.
278-
279292** Note:**
280293Blob objects of resized images can be created via
281294[ canvas.toBlob()] ( https://github.com/blueimp/JavaScript-Canvas-to-Blob ) .
282295
296+ The Meta data extension also adds additional options used for the
297+ ` parseMetaData ` method:
298+
299+ * ** maxMetaDataSize** : Maximum number of bytes of meta data to parse.
300+ * ** disableImageHead** : Disable parsing the original image head.
301+
283302### Exif parser
284303If you include the Load Image Exif Parser extension, the argument passed to the
285304callback for ** parseMetaData** will contain the additional property ** exif** if
0 commit comments