@@ -203,6 +203,28 @@ pass in an options object with the property `expanded` set to `true`:
203203const tags = ExifReader .load (fileBuffer, {expanded: true });
204204```
205205
206+ #### Read only part of file
207+
208+ If you only want to read part of the image file you can use the ` length ` option:
209+
210+ ``` javascript
211+ const tags = await ExifReader .load (filename, {length: 128 * 1024 });
212+ ```
213+
214+ This will load only the first 128 KiB of the file. This could be useful if you
215+ know the metadata is located at the beginning of the file. Just be aware that
216+ it's common for the metadata to be spread out over a larger area so please try
217+ it out on your set of files to know if it's suitable for your situation.
218+
219+ Note that this option only works when ExifReader handles the loading of the
220+ file. If e.g. a JavaScript File object from a form file field is passed into
221+ ExifReader the whole file will already have been loaded into memory and it's too
222+ late. More specifically the length option will work for 1. local files when
223+ running through Node.js, and 2. remote files when passing a URL. For the latter,
224+ if doing this through a web browser, make sure the remote server is either on
225+ the same origin (domain) as your script or that the server is passing correct
226+ CORS headers, specifically allowing the ` Range ` header.
227+
206228#### Unknown tags
207229
208230Tags that are unknown, either because they have been excluded by making a custom
425447 yourself to regular Exif tags you can most probably get by with only reading
426448 the first 128 kB. This may exclude IPTC and XMP metadata though (and
427449 possibly Exif too if they come in an irregular order) so please check if
428- this optimization fits your use case.
450+ this optimization fits your use case. Use the ` length ` option to only read
451+ the beginning of the file. See above for more details on that.
429452
430453Testing
431454-------
0 commit comments