Export/Import All Pics

SavatageSavatage Member Posts: 7,142
edited 2006-01-23 in Navision Attain
Here's the plan. I have 1000 item pics in my system. I can create a Picture Item book with Crystal Reports.

Problem is the report after a few pages generated crashes (just closes the program). I've played with the C/odbc setting with no luck. I believe it's due to the size of the BMP's installed in Navision. (between 300-500kb) each.

So I created a new Field on the item card called Picture2 and I imported a JPG (11-15kb each) file into it. I Know it can't be viewed in Navision BUT Crystal Does show the pic output.

So all I have to do is export every pic I have (which I did)
DataItemTableView:SORTING(No.) ORDER(Ascending) WHERE(Picture=FILTER(<>' '),Blocked=FILTER(No))
OnAfterGetRecord()
SETRANGE("No.");
IF Picture.HASVALUE THEN
  Picture.EXPORT('c:\'+Item."No."+'.BMP',FALSE);

Then using PIX resizer http://bluefive.pair.com/
I created a copy of all the BMP's into Small JPG.

Now I want to Import them all back into Navision into the BLOB called Picture2. Every item that has a Picture I want to import the new jpg.

So why doesn't the simple change of this report work:
OnAfterGetRecord()
SETRANGE("No.");
IF Picture.HASVALUE THEN
  Picture2.IMPORT('c:\'+Item."No."+'.JPG',FALSE);

It appears to work but when the report is over nothing is imported.

I can do it one at a time on the pic form - But that's no fun.
OnPush()
PictureExists := Picture.HASVALUE;
ImportedPicture := Picture2.IMPORT('C:\'+Item."No."+'.JPG',TRUE);
IF ImportedPicture = '' THEN
      EXIT;
CurrForm.SAVERECORD;

Codemasters Help!

Comments

  • nelsonnelson Member Posts: 107
    Are you MODIFYing the record?
    Nelson Alberto
  • SavatageSavatage Member Posts: 7,142
    edited 2006-01-23
    dohhh,
    Code: 
    OnAfterGetRecord() 
    SETRANGE("No."); 
    IF Picture.HASVALUE THEN 
      Picture2.IMPORT('c:\'+Item."No."+'.JPG',FALSE); 
    Item.MODIFY;
    
  • frankmortensenfrankmortensen Member Posts: 42
    If you are using a report to run through the records/pictures - you have to use "CALCFIELDS" on the picture field before testing for "HASVALUE".
    Otherwise "HASVALUE" will show false even if there is a picture saved in the BLOB.

    /Frank
  • krikikriki Member, Moderator Posts: 9,112
    It can also be interesting NOT to import the pics in Navision. This for keeping the DB smaller.
    I had once a customer with 15.000 items with jpg-pics of 100-500KB a picture (=1.5-7.5 GB!!!). They refused to convert it into bmp because it would be toooooo much in the DB. So I left them somewhere on the server (divided in several subdirs to not overload a subdir) and when an item-pic was needed, I converted it on-the-fly. For just viewing the pic of an item, it was perfect. When they printed a lot of them, the delay was noticable but acceptable.
    And very interesting:the DB remained small for making backups.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • SavatageSavatage Member Posts: 7,142
    kriki wrote:
    when an item-pic was needed, I converted it on-the-fly.

    Maybe you can explain a bit how you did this?

    Did you use this: http://www.navisioner.com/downloads/3rd ... vertor.zip
    This little tool allows you to keep your library of pictures separated from Navision, yet load the picture instantly into Navision when required for display or printing. The picture is converted instantly into the BMP format for Navision, without the user noticing it. When the resolution of a JPG picture has been set (in dots-per-inch or dots-per-centimeter), this is converted also to allow Navision to do a proper scaling. The zip file contains the converter as EXE file, a sample picture form to show the working (you have to provide some pictures yourself - see comments in the code) and the source code of the VB project. The Visual Basic runtime module (msvbvm60.dll) is not included. Either you have this on your system already, as part of the Office 2000 install, or you can download it from the Microsoft site, or one of the other download sites like www.winfiles.com or www.download.com The Multiformat Picture Converter is freeware, although I retain copyrights for it. Some feedback on use in your situation is appreciated.
  • krikikriki Member, Moderator Posts: 9,112
    I used "jpg2bmp.exe". It is a old DOS-command, but it still works nicely (except that everytime the DOS-prompt shows up, but this you can avoid using 'Windows Script Host Object Model'.WshShell => method Run).
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.