Import JPG on Fly & Show In Navision

Savatage
Member Posts: 7,142
It's been discussed how to save your Item pictures on an outside drive and show them in Nav on the fly as BMP. This way you Database doesn't grow out of control when you have to import 10000 pics into BLOB fields.
You can also have JPG pics on an outside drive and show them in Nav.
To Test use Form 346 item Picture
OnAfterGetRecord add
SETRANGE("No.");
ConvertPic Type Integer
i:\navision attain\jpg2bmp.exe //is the drive & directory of the EXE that I used, which you can find here: http://www.mibuso.com/dlinfo.asp?FileID=70
'P:\jpg\'+"No."+'.jpg' //is the directory we keep our JPG pics (P:\jpg) Also the pictures are named as it's Item Number hence the "No."
But you could easily change it to UPC or Vendor Item No if that's how you name your pics.
I have set the SCALE to 1/1 but the other choices are
half = 1/2
quarter = 1/4
eigth = 1/8
this will reduce the pic size.
Most pc's are fast today and the EXE file flashes it's little Dos box for an instance - I forgot the command that makes that invisible running behind the scenes. Perhaps stuffing it into a BAT file. anyway...
You can also have JPG pics on an outside drive and show them in Nav.
To Test use Form 346 item Picture
OnAfterGetRecord add
SETRANGE("No.");
IF EXISTS ('P:\jpg\'+"No."+'.jpg') THEN BEGIN ConvertPic:= SHELL('i:\navision attain\jpg2bmp.exe -outfile c:\temp.bmp -color 256 -bmp -scale 1/1 p:\jpg\'+"No."+'.jpg'); Picture.IMPORT('c:\temp.bmp',FALSE); END ELSE BEGIN CLEAR(Picture); END;
ConvertPic Type Integer
i:\navision attain\jpg2bmp.exe //is the drive & directory of the EXE that I used, which you can find here: http://www.mibuso.com/dlinfo.asp?FileID=70
'P:\jpg\'+"No."+'.jpg' //is the directory we keep our JPG pics (P:\jpg) Also the pictures are named as it's Item Number hence the "No."
But you could easily change it to UPC or Vendor Item No if that's how you name your pics.
I have set the SCALE to 1/1 but the other choices are
half = 1/2
quarter = 1/4
eigth = 1/8
this will reduce the pic size.
Most pc's are fast today and the EXE file flashes it's little Dos box for an instance - I forgot the command that makes that invisible running behind the scenes. Perhaps stuffing it into a BAT file. anyway...
0
Comments
-
I get error message when clicking Item->Picture:
Microsoft Business Solutions-Navision
The file name "C:\jpg\jpg2bmp\jpg2bmp.exe -outfile c:\temp.bmp -color 256 -bmp -scale 1/1 C:\jpg\1000.jpg" contains a character that may not be used.
Please check the file name. You can find additional information on file names in the documentation for your operating system.
OK
Any ideas, suggestions?
EDIT: if i execute same command from cmd line, it succeeds.Tomas,
Dynamics NAV Enthusiast0 -
Savatage wrote:I forgot the command that makes that invisible running behind the scenes. Perhaps stuffing it into a BAT file. anyway...
@Tomas : probably you need to put some parameters between double quotes.
[Topic moved from Navision Attain forum to Navision Tips & Tricks forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Path := 'C:\jpg\'; // might be defined in custom setup form and pointing to shared drive WindowsStyle := 0; // do not show cmd window WaitForCommand := TRUE; // wait for command to finish SETRANGE("No."); IF EXISTS (Path+"No."+'.jpg') THEN BEGIN CREATE(WShell); Cmd := Path+'jpg2bmp\jpg2bmp.exe -outfile '+Path+'temp.bmp -color 256 -bmp '+Path+"No."+'.jpg'; WShell.Run(Cmd,WindowsStyle,WaitForCommand); CLEAR(WShell); Picture.IMPORT(Path+'temp.bmp',FALSE); END ELSE BEGIN CLEAR(Picture); END;
The only issue left is that if we put images (and jpg2bmp.exe) on a shared drive, everytime we'll display image, we'll have to cofirm that we trust that program.
Otherwise, thanks Savatage and kriki for a wonderful tip! \:D/Tomas,
Dynamics NAV Enthusiast0 -
I don't get that issue - are you running Vista?0
-
Savatage wrote:I don't get that issue - are you running Vista?
Hmnz,
No. I am running on Windows XP. I have copied exe file to other computer and mapped a new drive for that folder. Each time I want to open Item Picture form I get Open File - Security Warning:The publisher could not be verified. Are you sure you want to run this software? Name: jpg2bmp.exe Publisher: Unknow Publisher Type: Application From: H:\jpg\jpg2bmp
Tomas,
Dynamics NAV Enthusiast0 -
From: H:\jpg\jpg2bmp
Perhaps if you save the jpg2bmp.exe from your client folder or a drive on your PC instead of having the program on a network drive - it will not think it's an outside program every time.0 -
Savatage wrote:From: H:\jpg\jpg2bmp
Perhaps if you save the jpg2bmp.exe from your client folder or a drive on your PC instead of having the program on a network drive - it will not think it's an outside program every time.
Yes, but this means, that you need to copy same program to all user machines, instead of placing it somewhere in the network in one place. :?Tomas,
Dynamics NAV Enthusiast0 -
you have to pick which is the lesser of two evils for your situation.
If you have 10 machines then it's not a problem
you have 100 then ouch!0 -
Yes, but this means, that you need to copy same program to all user machines, instead of placing it somewhere in the network in one place
I'ved solved this problem, it was an other progamm (DLL), as following:
I've stored my dll (which i needed on ever client pc) into a BLOB in a special table. When the user want's to run the Navision Object which need my DLL i checked before if this DLL is registerd (for example in table Automations) if it is not reg. i extract it from the BLOB to an defined folder and regist. it with regsrv / regasm. So the users can use my DLL /or others on every PC. The admins doesn't need to install this when they setup a new PC.
the same principle u can use for this problem .....
Regards
RenéDo you make it right, it works too!0 -
kinda sounds like this:
http://www.mibuso.com/howtoinfo.asp?FileID=50 -
Wow, Luc has the same idea .....
An other idea is, when you not will map the network drives, that u use the UNC path. For using UNC here in the forum are some examples.Do you make it right, it works too!0 -
I suspect this will stop working with vista and it will certainly not work on machines where the user is not an admin.
As an admin you can install a dll onto every machine in the network using the psexec tool from MS (www.sysinternals.com will take you to the correct page).
Two commands will do the trick and you can probably do it with one.
psexec \\* copy \\fromserver\fromshare\fromdll.dll c:\windows\system32\todll.dll
psexec \\* regsvr32 c:\windows\system32\todll.dll
psexec \\* executes the command on every machine in the network.
Ian0 -
hiii pros.. :shock:
I am new to navision but i tried the code given by Thomas. but when i compiled I got some problem ](*,)
1. Unknown Variable Wshell :-k
I can define this in Global but what is the data type is it a function?
2. Cmd unknown variable
And I have some more doubts where is this Windows Style: = 0; defined is it a property?
[-o<0 -
Prajeesh Nair wrote:hiii pros.. :shock:
I am new to navision but i tried the code given by Thomas. but when i compiled I got some problem ](*,)
1. Unknown Variable Wshell :-k
I can define this in Global but what is the data type is it a function?
2. Cmd unknown variable
And I have some more doubts where is this Windows Style: = 0; defined is it a property?
[-o<
Wshell->Datatype=Automation->Subtype=Windows Script Host Object Model->WshShell
I assume CMD is type integer0 -
Hi,
We're using the code below in form 30 (Item Card), and that works great.Path := 'C:\jpg\'; // might be defined in custom setup form and pointing to shared drive WindowsStyle := 0; // do not show cmd window WaitForCommand := TRUE; // wait for command to finish SETRANGE("No."); IF EXISTS (Path+"No."+'.jpg') THEN BEGIN CREATE(WShell); Cmd := Path+'jpg2bmp\jpg2bmp.exe -outfile '+Path+'temp.bmp -color 256 -bmp '+Path+"No."+'.jpg'; WShell.Run(Cmd,WindowsStyle,WaitForCommand); CLEAR(WShell); Picture.IMPORT(Path+'temp.bmp',FALSE); END ELSE BEGIN CLEAR(Picture); END;
We only encounter one strange problem. If a user keeps pressing the navigate buttons (Back or Forward) in the toolbar, a Navision messagebox pops up stating "Do you want to change the name of the record? (Yes - No)". This occurs just before a record that contains a picture is displayed. The result is that the previous item now shows the image which is wrong.
So what might be the problem regarding the messagebox and showing the image one record to early?
Hope someone has an answer.
Nico Dekker
The Netherlands0 -
So you showing the pic right on the item card & not using Item Picture form 346.
Which trigger to you have the code on? if I get a second I'll try your code and see what my results are.0 -
Tomas wrote:
Path := 'C:\jpg\'; // might be defined in custom setup form and pointing to shared drive WindowsStyle := 0; // do not show cmd window WaitForCommand := TRUE; // wait for command to finish SETRANGE("No."); IF EXISTS (Path+"No."+'.jpg') THEN BEGIN CREATE(WShell); Cmd := Path+'jpg2bmp\jpg2bmp.exe -outfile '+Path+'temp.bmp -color 256 -bmp '+Path+"No."+'.jpg'; WShell.Run(Cmd,WindowsStyle,WaitForCommand); CLEAR(WShell); Picture.IMPORT(Path+'temp.bmp',FALSE); END ELSE BEGIN CLEAR(Picture); END;
The only issue left is that if we put images (and jpg2bmp.exe) on a shared drive, everytime we'll display image, we'll have to cofirm that we trust that program.
Otherwise, thanks Savatage and kriki for a wonderful tip! \:D/
When i run this function then i found ole error
Microsoft Dynamics NAV
This message is for C/AL programmers:
An exception was raised in method Run. The OLE control or Automation server has returned error (HRESULT) -2147352567.
The component did not provide the exception description.
OK
now what i do
Thank's !!!
Devendra0 -
Wshell->Datatype=Automation->Subtype = Windows Script Host Object Model->WshShell
Cmd = Integer
WindowsStyle = Integer
WaitForCommand = Boolean
What do you have these declared as?0 -
I declared
Cmd = Text 250 and it works
Further I did generated temp.bmp in user level temp folder to avoid multi user conflict (Here the jpg name was based on "Design No." and there were multiple item with same design no. )
- Rajesh Asar0 -
When I did this I used IrfanView, it can convert and resize a lot of different image formats from the command line.Robert de Bath
TVision Technology Ltd0 -
When I run this function I also get following error message.
An exception was raised in method Run. The OLE control or Automation Server has returned error (HERSULT) -2147352567.
Can anyone please help.0 -
rajeshasar wrote:I declared
Cmd = Text 250 and it works
Further I did generated temp.bmp in user level temp folder to avoid multi user conflict (Here the jpg name was based on "Design No." and there were multiple item with same design no. )
- Rajesh Asar0 -
Dear all,
I have tried this technique to import the jpg file but the problem is the photo is not converted. i have taken "cmd" variable as text 250 because whenever i choose the datatype of this variable as integer, the error appears for the datatype "integer := text". the photo i have chosen is not converted to bmp. please suggest me where am i wrong??
Path := 'D:\';
WindowsStyle := 0;
WaitForCommand := TRUE;
SETRANGE("No.");
IF EXISTS (Path+"No."+'.jpg') THEN
BEGIN
CREATE(Wshell);
cmd := Path+'jpg2bmp\jpg2bmp.exe -outfile'+Path+"No."+'.bmp -color 256 -bmp'+Path+ "No."+'.jpg';
Wshell.Run(cmd,WindowsStyle,WaitForCommand);
CLEAR(Wshell);
Photo.IMPORT(Path+"No."+'.bmp',FALSE);
END
ELSE BEGIN
CLEAR(Photo);
END;0 -
is you executable in
\jpg2bmp\jpg2bmp.exe?
0 -
Suman Maharjan wrote:cmd := Path+'jpg2bmp\jpg2bmp.exe -outfile'+Path+"No."+'.bmp -color 256 -bmp'+Path+ "No."+'.jpg';
Looks like you're missing the spaces, you do have to be precise for this to work.
You can use a MESSAGE to popup the cmd that's being used and copy&paste that into a cmd shell to check.Robert de Bath
TVision Technology Ltd0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions