Loading...

empty string with SaveAsString("jpg")

Support for GdPicture Light Imaging Toolkit and GdPicture Pro Imaging ActiveX/SDK.

empty string with SaveAsString("jpg")

Postby al_foto » Sat Oct 31, 2009 1:50 pm

I'm using Imaging1.SaveAsString("jpg") and with some images I get returned an empty string "" with length 0. This only happens with a few jpg images, most of them are ok.
Have tried to resave the files with Photoshop to force rewritten the format with no luck.
They show fine in a gdviewer and it seems I can SaveAsString("gif") also but not as a jpg.

Code is just:
nImageId = Imaging1.CreateImageFromFile(fsoFile.path)
PicString = Imaging1.SaveAsString("jpg", 80)

Have tried with last version 5.12.3

Any help will be appreciated :wink:
al_foto
 
Posts: 12
Joined: Fri Aug 31, 2007 10:12 am

Re: empty string with SaveAsString("jpg")

Postby Loïc » Sat Oct 31, 2009 2:21 pm

Hi,

Please, send image generating this behavior to esupport (at) gdpicture (dot) com.

Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4430
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: empty string with SaveAsString("jpg")

Postby al_foto » Tue Nov 03, 2009 12:58 pm

Loïc,
hope you have received the sample picture.
Please find enclosed some more details:

In the compiler computer ( Vista 32 bits).
The picture loads , also in a GDViewer
I can not save as string
If I ResizeImage I can not SaveAsString
If I CreateThumbnail I can SaveAsString

In another PC ( Vista 64bits)
The picture loads, also in a GDViewer
I can SaveAsString
I can not CreateThumbnail and SaveAsString, it even doesn't load into a GdViewer after the createthumbnail

I'm really confused :(
al_foto
 
Posts: 12
Joined: Fri Aug 31, 2007 10:12 am

Re: empty string with SaveAsString("jpg")

Postby Loïc » Tue Nov 03, 2009 1:03 pm

Hi,

Unfortunately I was unable to reproduce your problem.

I guess your environment of dev. considers as "empty" a string which begin by chr(0).

The best practice is to save the image to an array of bytes. If you want some code sample I will happy to assist.

Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4430
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: empty string with SaveAsString("jpg")

Postby al_foto » Tue Nov 03, 2009 1:30 pm

Yes, please, a sample would be great. I have tried to search for it at the forum with no luck.

Thanks, :wink:
al_foto
 
Posts: 12
Joined: Fri Aug 31, 2007 10:12 am

Re: empty string with SaveAsString("jpg")

Postby Loïc » Tue Nov 03, 2009 1:33 pm

What is your programming language ?
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4430
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: empty string with SaveAsString("jpg")

Postby al_foto » Tue Nov 03, 2009 1:37 pm

Ouch, sorry. VB6.
I need to save the jpg thumbnail into an access database memo field, therefore I used SaveAsString to easily get the data later to a picture again.
Thanks.
al_foto
 
Posts: 12
Joined: Fri Aug 31, 2007 10:12 am

Re: empty string with SaveAsString("jpg")

Postby Loïc » Tue Nov 03, 2009 1:45 pm

Hi,

You should have a look on the ms access sample "demo_viewer.mdb"

Here a part of this sample (saving image in db):


Code: Select all
Private Sub Command55_Click()
   Dim arBytes() As Byte
     
   If Imaging1.SaveAsByteArray(arBytes, 0, "jpg") = 0 Then
      Me.Recordset.Edit
      Me.Recordset.Fields("Image").AppendChunk arBytes
      Me.Recordset.Update
      MsgBox "Image saved"
   End If
   Erase arBytes
End Sub


Hope this helps,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4430
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: empty string with SaveAsString("jpg")

Postby al_foto » Tue Nov 03, 2009 2:12 pm

Thanks, but I still have problems with this images even with byte arrays.
I have just created a project with only a form, one Imaging and one GdViewer.

Private Sub Command1_Click()
Dim PicBytes as Byte
Dim PicByteOk as Integer
Dim nImageId as Long

nImageId = Imaging1.CreateImageFromFile(App.Path + "\test.jpg")
GdViewer1.SetNativeImage(nImageId)
PicByteOk = Imaging1.SaveAsByteArray(PicBytes(),0,"jpg")
MsgBox(str(PicByteOk))

End Sub

The picture is loaded fine in the GdViewer but SaveAsByteArray ever gives 7 (Win32Error), the test.jpg picture is the one I sent you by email.
If I save the file as TIF with Photoshop, reload it as TIF and then save again as JPG all is fine but the initial JPG file is not ok. A couple of users have sent me this kind of files and they seem to be from CS4 saved as JPG but I know that not all CS4 files have this behavior.
al_foto
 
Posts: 12
Joined: Fri Aug 31, 2007 10:12 am

Re: empty string with SaveAsString("jpg")

Postby Loïc » Tue Nov 03, 2009 3:26 pm

Hi,

Your code is wrong.

Try this:


Dim PicBytes() As Byte
Dim PicByteOk As Integer
Dim nImageId As Long

nImageId = Imaging1.CreateImageFromFile("c:\test.jpg")
GdViewer1.SetNativeImage (nImageId)
PicByteOk = Imaging1.SaveAsByteArray(PicBytes(), 0, "jpg")
MsgBox (Str(PicByteOk))


If the problem persists, could you send me more images ?

Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4430
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: empty string with SaveAsString("jpg")

Postby al_foto » Tue Nov 03, 2009 3:34 pm

Sorry, I wrote it wrong in the message, the actual code is ok. :oops:
I'll send you more images by email now.
Thanks, :wink:
al_foto
 
Posts: 12
Joined: Fri Aug 31, 2007 10:12 am


Return to GdPicture [Pro] ActiveX

Who is online

Users browsing this forum: No registered users and 1 guest

cron