# UPDATED: 'Error while reading JPEG file: Application transferred too few scanlines'

**URL:** <https://forums.fusetools.com/t/updated-error-while-reading-jpeg-file-application-transferred-too-few-scanlines/7741>\
**Category:** Bug Reports\
**Created:** [May 15, 2019, 3:23pm UTC](https://forums.fusetools.com/t/updated-error-while-reading-jpeg-file-application-transferred-too-few-scanlines/7741 "2019-05-15T15:23:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Enrico](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/enrico/32/144_2.png) [@Enrico](https://forums.fusetools.com/u/Enrico)\
**Post date:** [May 15, 2019, 3:23pm UTC](https://forums.fusetools.com/t/updated-error-while-reading-jpeg-file-application-transferred-too-few-scanlines/7741/1 "2019-05-15T15:23:37Z")

</div>

The following code will not display the selected image with CameraRoll if built and installed on a iPhone via XCode which will report the error:

`Loading image from file failed. Error while reading JPEG file: Application transferred too few scanlines`

If the same code is exported to the iPhone from Fusetools Studio it does work correctly. The code does work properly (export and preview) in Android.

```
<App>

    <JavaScript>
        var Observable = require("FuseJS/Observable");
        var cameraRoll = require("FuseJS/CameraRoll");
        var ImageTools = require('FuseJS/ImageTools');

        var selectedImage = Observable();
    
        function browseImage() {
            cameraRoll.getImage().then(function(image) {
                selectedImage.value = image.path;
            }, function(error) {
                console.log(error);
            });
        };

        function cancelImage() {
            selectedImage.value = "";
        }

        module.exports = {
            selectedImage: selectedImage,
            browseImage: browseImage,
            cancelImage: cancelImage,
        };

    </JavaScript>
  
    <StackPanel Alignment="Center" Width="100%" Margin="10,0,10,0" ux:Name="form">
        <Rectangle>
            <Stroke Width="1" Color="#CCCCCC" />
            <StackPanel>
                <WhileString Value="{selectedImage}" Test="IsEmpty">
                    <Text Value="[Image placeholder]" FontSize="12" TextAlignment="Center" Margin="0,12,0,0"/>
                </WhileString>
                <WhileString Value="{selectedImage}" Test="IsNotEmpty">
                    <Image File="{selectedImage}" MaxHeight="200" Margin="0,12,0,0"/>
                </WhileString>                
                <Grid RowCount="1" ColumnCount="2" CellSpacing="8" Margin="0,12,0,12">
                    <Button Row="0" Column="0" Text="Remove image" Clicked="{cancelImage}" />
                    <Button Row="0" Column="1" Text="Browse gallery" Clicked="{browseImage}" />
                </Grid>
            </StackPanel>
        </Rectangle>
        <Button Text="Invia" Clicked="{sendData}" Margin="0,10,0,0" />
    </StackPanel>

</App>

```

Tested with:  
MacOS High Sierra 10.13 and Mojave 10.14  
XCode 9.4.1 and 10.2.1  
Fuse 1.10.0-rc1  
iPhone 5s with iOS 12.3

Error reported in [github](https://github.com/fuse-open/fuselibs/issues/1272).

---

<div class="post-metadata">

**Author:** ![Enrico](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/enrico/32/144_2.png) [@Enrico](https://forums.fusetools.com/u/Enrico)\
**Post date:** [May 31, 2019, 10:32am UTC](https://forums.fusetools.com/t/updated-error-while-reading-jpeg-file-application-transferred-too-few-scanlines/7741/2 "2019-05-31T10:32:43Z")

</div>

SOLVED.  
Seem to have found a workaround: resize the image before displaying it. See [github](https://github.com/fuse-open/fuselibs/issues/1272) for the code.
