@@ -64,15 +64,15 @@ Or alternatively, choose which components you want to include:
6464In your application code, use the ** loadImage()** function like this:
6565
6666``` js
67- document .getElementById (" file-input" ).onchange = function (e ) {
67+ document .getElementById (' file-input' ).onchange = function (e ) {
6868 loadImage (
6969 e .target .files [0 ],
70- function (img ) {
71- document .body .appendChild (img);
70+ function (img ) {
71+ document .body .appendChild (img)
7272 },
7373 { maxWidth: 600 } // Options
74- );
75- };
74+ )
75+ }
7676```
7777
7878### Image scaling
8484var scaledImage = loadImage .scale (
8585 img, // img or canvas element
8686 { maxWidth: 600 }
87- );
87+ )
8888```
8989
9090## Requirements
@@ -112,18 +112,18 @@ It always returns a HTML
112112passing an image URL:
113113
114114``` js
115- document .getElementById (" file-input" ).onchange = function (e ) {
115+ document .getElementById (' file-input' ).onchange = function (e ) {
116116 var loadingImage = loadImage (
117117 e .target .files [0 ],
118- function (img ) {
119- document .body .appendChild (img);
118+ function (img ) {
119+ document .body .appendChild (img)
120120 },
121121 { maxWidth: 600 }
122- );
122+ )
123123 if (! loadingImage) {
124124 // Alternative code ...
125125 }
126- };
126+ }
127127```
128128
129129The ** img** element or
@@ -132,16 +132,16 @@ the **loadImage()** function allows to abort the loading process by setting the
132132** onload** and ** onerror** event handlers to null:
133133
134134``` js
135- document .getElementById (" file-input" ).onchange = function (e ) {
135+ document .getElementById (' file-input' ).onchange = function (e ) {
136136 var loadingImage = loadImage (
137137 e .target .files [0 ],
138- function (img ) {
139- document .body .appendChild (img);
138+ function (img ) {
139+ document .body .appendChild (img)
140140 },
141141 { maxWidth: 600 }
142- );
143- loadingImage .onload = loadingImage .onerror = null ;
144- };
142+ )
143+ loadingImage .onload = loadingImage .onerror = null
144+ }
145145```
146146
147147The second argument must be a ** callback** function, which is called when the
@@ -154,20 +154,20 @@ The second is on object with the original image dimensions as properties and
154154potentially additional [ meta data] ( #meta-data-parsing ) :
155155
156156``` js
157- var imageUrl = " https://example.org/image.png" ;
157+ var imageUrl = ' https://example.org/image.png'
158158loadImage (
159159 imageUrl,
160- function (img , data ) {
161- if (img .type === " error" ) {
162- console .error (" Error loading image " + imageUrl);
160+ function (img , data ) {
161+ if (img .type === ' error' ) {
162+ console .error (' Error loading image ' + imageUrl)
163163 } else {
164- document .body .appendChild (img);
165- console .log (" Original image width: " , data .originalWidth );
166- console .log (" Original image height: " , data .originalHeight );
164+ document .body .appendChild (img)
165+ console .log (' Original image width: ' , data .originalWidth )
166+ console .log (' Original image height: ' , data .originalHeight )
167167 }
168168 },
169169 { maxWidth: 600 }
170- );
170+ )
171171```
172172
173173## Options
@@ -242,8 +242,8 @@ They can be used the following way:
242242``` js
243243loadImage (
244244 fileOrBlobOrUrl,
245- function (img ) {
246- document .body .appendChild (img);
245+ function (img ) {
246+ document .body .appendChild (img)
247247 },
248248 {
249249 maxWidth: 600 ,
@@ -252,7 +252,7 @@ loadImage(
252252 minHeight: 50 ,
253253 canvas: true
254254 }
255- );
255+ )
256256```
257257
258258All settings are optional. By default, the image is returned as HTML ** img**
@@ -266,13 +266,13 @@ meta data automatically with the `meta` option:
266266``` js
267267loadImage (
268268 fileOrBlobOrUrl,
269- function (img , data ) {
270- console .log (" Original image head: " , data .imageHead );
271- console .log (" Exif data: " , data .exif ); // requires exif extension
272- console .log (" IPTC data: " , data .iptc ); // requires iptc extension
269+ function (img , data ) {
270+ console .log (' Original image head: ' , data .imageHead )
271+ console .log (' Exif data: ' , data .exif ) // requires exif extension
272+ console .log (' IPTC data: ' , data .iptc ) // requires iptc extension
273273 },
274274 { meta: true }
275- );
275+ )
276276```
277277
278278The extension also provides the method ** loadImage.parseMetaData** , which can be
@@ -281,9 +281,9 @@ used the following way:
281281``` js
282282loadImage .parseMetaData (
283283 fileOrBlob,
284- function (data ) {
284+ function (data ) {
285285 if (! data .imageHead ) {
286- return ;
286+ return
287287 }
288288 // Combine data.imageHead with the image body of a resized file
289289 // to create scaled images with the original image meta data, e.g.:
@@ -295,13 +295,13 @@ loadImage.parseMetaData(
295295 loadImage .blobSlice .call (resizedImageBlob, 20 )
296296 ],
297297 { type: resizedImageBlob .type }
298- );
298+ )
299299 },
300300 {
301301 maxMetaDataSize: 262144 ,
302302 disableImageHead: false
303303 }
304- );
304+ )
305305```
306306
307307** Note:**
@@ -322,14 +322,14 @@ Exif data could be found in the given image.
322322The ** exif** object stores the parsed Exif tags:
323323
324324``` js
325- var orientation = data .exif [0x0112 ];
325+ var orientation = data .exif [0x0112 ]
326326```
327327
328328It also provides an ** exif.get()** method to retrieve the tag value via the
329329tag's mapped name:
330330
331331``` js
332- var orientation = data .exif .get (" Orientation" );
332+ var orientation = data .exif .get (' Orientation' )
333333```
334334
335335By default, the only available mapped names are ** Orientation** and
@@ -339,10 +339,10 @@ become available, as well as two additional methods, **exif.getText()** and
339339** exif.getAll()** :
340340
341341``` js
342- var flashText = data .exif .getText (" Flash" ); // e.g.: 'Flash fired, auto mode',
342+ var flashText = data .exif .getText (' Flash' ) // e.g.: 'Flash fired, auto mode',
343343
344344// A map of all parsed tags with their mapped names/text as keys/values:
345- var allTags = data .exif .getAll ();
345+ var allTags = data .exif .getAll ()
346346```
347347
348348The Exif parser also adds additional options for the parseMetaData method, to
@@ -361,14 +361,14 @@ IPTC data could be found in the given image.
361361The ** iptc** object stores the parsed IPTC tags:
362362
363363``` js
364- var objectname = data .iptc [0x5 ];
364+ var objectname = data .iptc [0x5 ]
365365```
366366
367367It also provides an ** iptc.get()** method to retrieve the tag value via the
368368tag's mapped name:
369369
370370``` js
371- var objectname = data .iptc .get (" ObjectName" );
371+ var objectname = data .iptc .get (' ObjectName' )
372372```
373373
374374By default, the only available mapped names are ** ObjectName** .
@@ -377,10 +377,10 @@ become available, as well as two additional methods, **iptc.getText()** and
377377** iptc.getAll()** :
378378
379379``` js
380- var keywords = data .iptc .getText (" Keywords" ); // e.g.: ['Weather','Sky']
380+ var keywords = data .iptc .getText (' Keywords' ) // e.g.: ['Weather','Sky']
381381
382382// A map of all parsed tags with their mapped names/text as keys/values:
383- var allTags = data .iptc .getAll ();
383+ var allTags = data .iptc .getAll ()
384384```
385385
386386The IPTC parser also adds additional options for the parseMetaData method, to
0 commit comments