In This Topic
Programming / Document Loading & Saving / Loading images from FTP server, processing and saving them back

Loading images from FTP server, processing and saving them back

In This Topic

In this tutorial, we will show you how to load your image from a server using the FTP protocol. Then you can process the image and save it back to the server using the FTP protocol again.

Copy Code
'We assume that GdPicture has been correctly installed and unlocked.

Dim oGdPictureImaging As New GdPictureImaging()

'Loading an image from FTP server.

Dim imageId As Integer = oGdPictureImaging.CreateGdPictureImageFromFTP("ftp.gdpicture.com", "/images/barcode.jpg", "user", "1234", 21)

If oGdPictureImaging.GetStat() <> GdPictureStatus.OK Then

    MessageBox.Show("The file can't be loaded. Status: " + oGdPictureImaging.GetStat().ToString(), "Loading images Example", MessageBoxButtons.OK, MessageBoxIcon.Error)

Else

    'Here you can do your processing, for example, remove the lines from the image.

    Dim status As GdPictureStatus = oGdPictureImaging.RemoveLines(imageId, LineRemoveOrientation.Horizontal Or LineRemoveOrientation.Horizontal)

    If status <> GdPictureStatus.OK Then

        MessageBox.Show("Error: " + oGdPictureImaging.GetStat().ToString(), "Loading images Example", MessageBoxButtons.OK, MessageBoxIcon.Error)

    Else

        'After you are done with your processing, you can save the image back to the server.

        status = oGdPictureImaging.SaveToFTP(imageId, DocumentFormat.DocumentFormatJPEG, 100, "ftp.gdpicture.com", "/images/barcode.jpg", "user", "1234", 21)

        If status <> GdPictureStatus.OK Then

            MessageBox.Show("Error: " + oGdPictureImaging.GetStat().ToString(), "Loading images Example", MessageBoxButtons.OK, MessageBoxIcon.Error)

        End If

    End If

    'Do not forget to release the used image.

    oGdPictureImaging.ReleaseGdPictureImage(imageId)

End If

oGdPictureImaging.Dispose()
Copy Code
//We assume that GdPicture has been correctly installed and unlocked.

GdPictureImaging oGdPictureImaging = new GdPictureImaging();

//Loading an image from FTP server.

int imageId = oGdPictureImaging.CreateGdPictureImageFromFTP("ftp.gdpicture.com", "/images/barcode.jpg", "user", "1234", 21);

if (oGdPictureImaging.GetStat() != GdPictureStatus.OK)

{

    MessageBox.Show("The file can't be loaded. Status: " + oGdPictureImaging.GetStat().ToString(), "Loading images Example", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

else

{

    //Here you can do your processing, for example, remove the lines from the image.

    GdPictureStatus status = oGdPictureImaging.RemoveLines(imageId, LineRemoveOrientation.Horizontal | LineRemoveOrientation.Horizontal);

    if (status != GdPictureStatus.OK)

    {

        MessageBox.Show("Error: " + oGdPictureImaging.GetStat().ToString(), "Loading images Example", MessageBoxButtons.OK, MessageBoxIcon.Error);

    }

    else

    {

        //After you are done with your processing, you can save the image back to the server.

        status = oGdPictureImaging.SaveToFTP(imageId, DocumentFormat.DocumentFormatJPEG, 100, "ftp.gdpicture.com", "/images/barcode.jpg", "user", "1234", 21);

        if (status != GdPictureStatus.OK)

        {

            MessageBox.Show("Error: " + oGdPictureImaging.GetStat().ToString(), "Loading images Example", MessageBoxButtons.OK, MessageBoxIcon.Error);

        }

    }

    //Do not forget to release the used image.

    oGdPictureImaging.ReleaseGdPictureImage(imageId);

}

oGdPictureImaging.Dispose();