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

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.

SOLVED.
Seem to have found a workaround: resize the image before displaying it. See github for the code.

1 Like