mibuso.com

Microsoft Business Solutions online community
It is currently Sun May 19, 2013 11:13 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Import JPG on Fly & Show In Navision
PostPosted: Tue May 20, 2008 11:26 pm 
Offline
MVP Microsoft Dynamics NAV
Site Supporter

Joined: Fri Jun 06, 2003 9:01 pm
Posts: 6977
Location: L.I., New York
Country: United States (us)
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.");
Code: Select all
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...

_________________
Harry Ruiz
http://www.cosmeticsolutions.com
http://www.autismspeaks.org


Top
 Profile E-mail WWW  
 
 Post subject:
PostPosted: Wed May 21, 2008 9:18 am 
Offline

Joined: Tue Aug 28, 2007 5:41 pm
Posts: 352
Location: Cambridge
Country: United Kingdom (uk)
I get error message when clicking Item->Picture:

Quote:
---------------------------
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.


Top
 Profile  
 
 Post subject: Re: Import JPG on Fly & Show In Navision
PostPosted: Wed May 21, 2008 10:31 am 
Offline
Moderator
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Wed Jul 02, 2003 10:13 am
Posts: 7493
Location: Milan
Country: Italy (it)
Savatage wrote:
I forgot the command that makes that invisible running behind the scenes. Perhaps stuffing it into a BAT file. anyway...

Check this : http://www.mibuso.com/forum/viewtopic.php?t=12417 and use WindowStyle=0.

@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
Use the SEARCH,Luke! || No PM,please use the forum. || May the <SOLVED>-attribute be in your title! || Read Forum Rules before making a posting


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 21, 2008 12:05 pm 
Offline

Joined: Tue Aug 28, 2007 5:41 pm
Posts: 352
Location: Cambridge
Country: United Kingdom (uk)
Code: Select all
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/


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 22, 2008 4:30 pm 
Offline
MVP Microsoft Dynamics NAV
Site Supporter

Joined: Fri Jun 06, 2003 9:01 pm
Posts: 6977
Location: L.I., New York
Country: United States (us)
I don't get that issue - are you running Vista?

_________________
Harry Ruiz
http://www.cosmeticsolutions.com
http://www.autismspeaks.org


Top
 Profile E-mail WWW  
 
 Post subject:
PostPosted: Thu May 22, 2008 4:37 pm 
Offline

Joined: Tue Aug 28, 2007 5:41 pm
Posts: 352
Location: Cambridge
Country: United Kingdom (uk)
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:

Code: Select all
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 25, 2008 2:23 pm 
Offline
MVP Microsoft Dynamics NAV
Site Supporter

Joined: Fri Jun 06, 2003 9:01 pm
Posts: 6977
Location: L.I., New York
Country: United States (us)
Quote:
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.

_________________
Harry Ruiz
http://www.cosmeticsolutions.com
http://www.autismspeaks.org


Top
 Profile E-mail WWW  
 
 Post subject:
PostPosted: Thu Sep 18, 2008 5:20 pm 
Offline

Joined: Tue Aug 28, 2007 5:41 pm
Posts: 352
Location: Cambridge
Country: United Kingdom (uk)
Savatage wrote:
Quote:
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 Enthusiast


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 18, 2008 5:50 pm 
Offline
MVP Microsoft Dynamics NAV
Site Supporter

Joined: Fri Jun 06, 2003 9:01 pm
Posts: 6977
Location: L.I., New York
Country: United States (us)
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!

_________________
Harry Ruiz
http://www.cosmeticsolutions.com
http://www.autismspeaks.org


Top
 Profile E-mail WWW  
 
 Post subject:
PostPosted: Thu Sep 18, 2008 5:54 pm 
Offline

Joined: Mon Mar 08, 2004 2:42 pm
Posts: 3255
Location: Hannover
Country: Germany (de)
Quote:
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!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 18, 2008 6:35 pm 
Offline
MVP Microsoft Dynamics NAV
Site Supporter

Joined: Fri Jun 06, 2003 9:01 pm
Posts: 6977
Location: L.I., New York
Country: United States (us)
kinda sounds like this:
http://www.mibuso.com/howtoinfo.asp?FileID=5

_________________
Harry Ruiz
http://www.cosmeticsolutions.com
http://www.autismspeaks.org


Top
 Profile E-mail WWW  
 
 Post subject:
PostPosted: Thu Sep 18, 2008 7:14 pm 
Offline

Joined: Mon Mar 08, 2004 2:42 pm
Posts: 3255
Location: Hannover
Country: Germany (de)
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!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 18, 2008 8:21 pm 
Offline

Joined: Thu Mar 13, 2008 2:03 pm
Posts: 240
Location: Vizcaya
Country: Spain (es)
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.

Ian


Top
 Profile E-mail WWW  
 
 Post subject: Import JPG on Fly & Show In Navision Novice nav user
PostPosted: Wed Oct 01, 2008 2:23 pm 
Offline

Joined: Mon Sep 29, 2008 7:02 am
Posts: 47
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<


Top
 Profile E-mail  
 
 Post subject: Re: Import JPG on Fly & Show In Navision Novice nav user
PostPosted: Wed Oct 01, 2008 3:34 pm 
Offline
MVP Microsoft Dynamics NAV
Site Supporter

Joined: Fri Jun 06, 2003 9:01 pm
Posts: 6977
Location: L.I., New York
Country: United States (us)
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 integer

_________________
Harry Ruiz
http://www.cosmeticsolutions.com
http://www.autismspeaks.org


Top
 Profile E-mail WWW  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: