Get a Jumpstart with our Sample Apps
Results 1 to 16 of 16

Thread: Create a JPG/Imagemagick

  1. #1
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,733

    Default Create a JPG/Imagemagick

    We store images of certain types of ID cards in our system. Normally we scan the cards, which takes time to complete and can be problematic at very busy times. OK, says the client, I accept that we have to scan other companies' ID cards, but why do we have to scan our own, why can't we just create the JPG ourselves?

    We create our ID cards by printing an A5 report to an ID Card printer and the card is mailed to the customer. We usually print 50 or more cards n a session and we'd like to avoid having to scan the card before mailing. Going through the card scan/import multi-step process in the application is time consuming. We can't print to JPG like we can to a PDF, so what to do?

    The only thing I can think of is to (1) print the physical card then (2) immediately save the card image as PDF and then (3) use some sort of a converter to convert the PDF to a JPG. Imagemagick is the only program that converts this way (I think) and has a command line interface.

    Has anyone tried anything like this before?
    Finian

  2. #2
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    4,089

    Default Re: Create a JPG/Imagemagick

    Hi Finian,
    Usually I'm able to track you thought's but I'm am pretty lost with this one.

    ...why can't we just create the JPG ourselves?"
    We can't print to JPG like we can to a PDF, so what to do?
    ..print the physical card then (2) immediately save the card image as PDF and then (3) use some sort of a converter to convert the PDF to a JPG.
    I'm a little confused about what you are trying to accomplish. Are you trying to store the all card images as jpg and then produce the cards as pdf?
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  3. #3
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    4,089

    Default Re: Create a JPG/Imagemagick

    Is this one of those moments where technology that was useful and used routinely and fast (camera feeds with twain), would do you well instead of current technology (scanning ) which is time consuming and inneficient?
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  4. #4
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,733

    Default Re: Create a JPG/Imagemagick

    They are a recycling business and in Texas, you can only be paid cash for metals if you have a cash transaction Card. The cards are issued by the recycling yards and we accept cards from dozens of companies.

    We are required to examine/verify every cash card that is presented for every ticket. We insert a scanned image of the card presented (a customer could have 2 or 3 current cash cards) into the ticket and would prefer not to have to scan every time we need the image. For our own cards, we want to avoid even that first scan, hence my desire to create the image, without scanning, at the time we create the card we mail to the customer. If you have card applications from 50 customers that need to be mailed, it substantially increases the time spent getting the cards out if we have to scan them as well.

    So my idea is that our print button will print directly to the ID card printer (which we do now), but then save the card report as a PDF, just to be able to convert the pdf "image" to jpg. We won't store the pdf, all I'm interested in is getting the card from my Alpha report into a jpg as easily as I can. AFAIK, and I could be wrong, there isn't a way to do this directly from inside Alpha.
    Finian

  5. #5
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    4,089

    Default Re: Create a JPG/Imagemagick

    Hi Finian,
    I'm trying to get a handle on your situation. I deal with a tremendous number of image file exchanges in lots of formats, and I might be able to help or not.

    You can only be paid cash for metals if you have a cash transaction Card. The cards are issued by the recycling yards and we accept cards from dozens of companies.
    So you are the company that accepts the cards and makes payments?
    We insert a scanned image of the card presented (a customer could have 2 or 3 current cash cards) into the ticket and would prefer not to have to scan every time we need the image.
    So these are cards that are multiple-use cards? The yards don't give a virgin card with each delivery and the card holder gives you a single use card and you give them the cash and transaction and card done? The card is returned to the holder and can be "recharged' at the yard and brought back to you "recharged" with a new payment amount?
    For our own cards,
    So you are both a yard and a payment center?
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  6. #6
    "Certified" Alphaholic Ted Giles's Avatar
    Real Name
    Ted Giles
    Join Date
    Aug 2000
    Location
    In the Wolds, Louth, Lincolnshire, UK
    Posts
    3,782

    Default Re: Create a JPG/Imagemagick

    Finian, I am a bit late on this, but I am involved in summat similar. I import jpeg images to a form, create a report document and save as pdf.
    Can you not save as pdf and also as jpg/jpeg whatever?

    Edit, no you cannot easily.
    One way is using the Snipping Tool to select the document/image as a jpg which seems to be the default setting
    Then save wherever.

    'Open program: C:\Windows\Sysnative\SnippingTool.exe
    if file.exists("C:\Windows\Sysnative\SnippingTool.exe") then
    sys_shell("C:\Windows\Sysnative\SnippingTool.exe ",1)
    else
    ui_msg_box("Error Opening Program","File 'C:\Windows\Sysnative\SnippingTool.exe' does not exist.",ui_stop_symbol)
    end if

    I added this on a process to save the Pdf document button after verification is was correct, The PDF is saved, and the snipping tool fires next.
    If you need to save as a particular JPG file name, you can always set the Save to Clipboard to a constructed variable which the user can Ctrl+v into the name field;
    <FIELD>.VALUE_PUT( Field_Value as A [, Clipboard_Format as N ] )


    Saving as HTML or RTF works too, but sizing for JPG's is an issue.
    Last edited by Ted Giles; 11-09-2017 at 09:01 AM.
    Ted Giles
    Example Consulting - UK
    .

    https://exampleltd.example-software.com/

  7. #7
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,648

    Default Re: Create a JPG/Imagemagick

    Are you printing the cards one at a time or is the report a multipage report?

    I just did some testing and you can use the onprintexit event, when previewing a report, to capture a jpg of a specified area of the preview screen. It might take some doing to determine the proper area of the screen to capture and I don't know how it would perform on different monitors but this seems to work. I am also unsure if this would be any time savings - having to preview each card individually.

    Code:
    dim b1 as B
    ui_bitmap_create_from_screen("test", 2, 2, 4, 3)
    b1 = ui_bitmap_save("test")
    my_jpeg = bitmap_to_jpeg(b1)
    ptr = file.create("c:\temp\somename.jpg", FILE_RW_EXCLUSIVE)
    ptr.writeb(my_jpeg)
    ptr.close()
    If you have a multipage report, since you are printing one card per page, you should be able to use the detail section onrecord event. Suppose there is an id field on the report.

    Code:
    ident = id.value
    dim b1 as B
    ui_bitmap_create_from_screen("test", 0, 0, 4, 3)
    b1 = ui_bitmap_save("test")
    my_jpeg = bitmap_to_jpeg(b1)
    ptr = file.create("c:\temp\\"+alltrim(ident)+".jpg", FILE_RW_EXCLUSIVE)
    ptr.writeb(my_jpeg)
    ptr.close()
    As you page through the preview of the report the above creates a jpg of the specified screen area named for each id.
    Last edited by Stan Mathews; 11-09-2017 at 12:48 PM.
    There can be only one.

  8. #8
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,733

    Default Re: Create a JPG/Imagemagick

    Thanks guys. I've been diverted from this for the past couple of days.

    Mike: we accept any current cash card presented. It can be from another yard, no problem. Once we get our own card into that person's hands, that's the card they usually use. We pay them for the metals they bring. In cash. The business is highly monitored. We upload details of every transaction, every day, with pictures, to a service used by all the local police departments

    Stan: not to confuse things but: there is an official card application, complete with picture, fingerprint, id images that we prepare and print to pdf and which we must retain. Until the customer gets the actual card, the application suffices to allow us to buy from them. We now print our own card direct to a dedicated card printer then print a label and mail the card. We are required to mail the card as a means of verifying the mailing address. So it's a single page document, but previewing/selecting wouldn't really work here. I need something that just happens. Thanks for the suggestion, though, I hadn't thought of that and it will come in handy elsewhere.

    Ted: thanks for the Snipping tool (sound like an implement of torture) idea. Do you happen to know if it can run without intervention? The card image, if we also saved it as a pdf, would be consistent in size. But this would only work if it can be automatic. I'll get the tool and start investigating.

    Mike: I'm looking for a flow that would go as follows: (1) print the card to the card printer then (2) save the card image as PDF so that (3) I can somehow convert that PDF to a JPG. I thought that ImageMagick would be the answer for step 3. It can certainly, according to examples and comments, do the conversion, but I can't get out of the gate. I get a "File Not Found" error no matter how I feed the ImageMagick "Convert" program.

    As soon as I can get to it, I'll reinstall ImageMagick with every option available, maybe I left something out. If anyone has used ImageMagick and can give me a clue about the "file not found" business I'd appreciate it. I'm certain that I'm passing in the correct file and path and can't understand why it's not working.
    Finian

  9. #9
    "Certified" Alphaholic Ted Giles's Avatar
    Real Name
    Ted Giles
    Join Date
    Aug 2000
    Location
    In the Wolds, Louth, Lincolnshire, UK
    Posts
    3,782

    Default Re: Create a JPG/Imagemagick

    https://www.imagemagick.org/discours...ic.php?t=31529

    Its about fnf.

    Finian, the implement of torture is standard windows feature now. Not sure about automating unless you use a macro.
    Ted Giles
    Example Consulting - UK
    .

    https://exampleltd.example-software.com/

  10. #10
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,733

    Default Re: Create a JPG/Imagemagick

    it turns out the latest version of ImageMagick was fine, but I had not installed GhostScript which Imagemagick apparently uses in its conversions. Once I installed Ghostscript I was able to convert a PDF to a JPG so I can move ahead with coding the auto-run of the cmd file to actually do the conversion.

    Here's the sample command line I used

    magick -density 325 e:\temp5\test.pdf -resize 25% -background white -flatten e:\temp5\test.jpg

    I show this in case anyone tries something similar. All the conversion examples I tried (until today) used the "Convert" command. That was incorrect for this later version of ImageMagick where you are expected to use the "Magick" command for conversions.

    I'll be able to play with the conversion options once I see what the converted cash card file looks like.

    Thanks to all for the suggestions and ideas.
    Finian

  11. #11
    "Certified" Alphaholic Ted Giles's Avatar
    Real Name
    Ted Giles
    Join Date
    Aug 2000
    Location
    In the Wolds, Louth, Lincolnshire, UK
    Posts
    3,782

    Default Re: Create a JPG/Imagemagick

    Good stuff Finian
    Ted Giles
    Example Consulting - UK
    .

    https://exampleltd.example-software.com/

  12. #12
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    4,089

    Default Re: Create a JPG/Imagemagick

    Thanks Finian,
    I'm headed to look into this myself.
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  13. #13
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,733

    Default Re: Create a JPG/Imagemagick

    Full disclosure, this isn't working out quite as I hoped. I can convert PDF to JPG OK, but I hadn't really thought about what the PDF output looks like. Duh! It looks like a one page document and converts to look like that too. Now I have to figure out if/how an Imagemagick conversion can crop the 8.5X11 PDF image to something like 3X5 size and solve some font problems.
    Finian

  14. #14
    "Certified" Alphaholic kkfin's Avatar
    Real Name
    Kenneth
    Join Date
    Dec 2006
    Posts
    1,288

    Default Re: Create a JPG/Imagemagick

    If you can convert pdf to image (png, jpg, bmp) then you can use some node library to easily manipulate this image if needed. For example Jimp.

    You just need to write proper node_service (jimp.js) to use in Alpha. Like this (just example):

    Code:
    exports.handler = function(packet,response,sendResponse) {
    	var e;
            var attachments = null;
    	var Jimp = require("jimp");
    	Jimp.read(packet.picture,function(err, image){
    	image.resize(256,256).write("./smaller.jpg");
    	})
        // you can use msg to send  error or other msg back to xbasic 
        var msg = "some message";
        response.result = msg;
        sendResponse(response,attachments);
    };
    And then call this service in xbasic script:

    Code:
    dim p as p
    p.picture = "original.png"
    dim Pout as p
    Pout=node_request("jimp",p)
    The result is 256px*256px picture smaller.jpg.

    There are many other options in Jimp. to manipulate images.

    Ken

  15. #15
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,733

    Default Re: Create a JPG/Imagemagick

    Thanks Ken, that was an option I hadn't even considered. If/when I have time, I will return to the struggle where I "need to write proper node_service (jimp.js) to use in Alpha." This has, from the beginning, defeated my pretty superficial efforts to use node.js. All the examples and discussions assume more knowledge of Javascript than I possess and have left me stranded, so to speak. I'm still, off and on, trying to figure out how to do this with ImageMagick.
    Finian

  16. #16
    "Certified" Alphaholic kkfin's Avatar
    Real Name
    Kenneth
    Join Date
    Dec 2006
    Posts
    1,288

    Default Re: Create a JPG/Imagemagick

    In desktop there is always the Node option available. That is the reason I did give the example. Maybe for someone else how reads later this thread and have same problem.

    Anyway all javascript is written for you in Node Jimp module that is the hole point in Node. You just have to call functions written for you and they are documented and when you have the node_service skeleton everything is quite easy. Maybe.

    Ken

Similar Threads

  1. ImageMagick Crashing, Causing Application Server to Stop Working
    By Rich Hartnett in forum Mobile & Browser Applications
    Replies: 3
    Last Post: 12-25-2016, 04:54 AM
  2. Can not create any more UX
    By m.fotouhi@actportal.com in forum Mobile & Browser Applications
    Replies: 1
    Last Post: 09-16-2014, 09:16 AM
  3. How to create DIV in UX
    By wei243 in forum Mobile & Browser Applications
    Replies: 6
    Last Post: 06-14-2014, 03:05 AM
  4. Imagemagick security bug in V11 2549 build 3903
    By Justus in forum Application Server Version 11 - Web/Browser Applications
    Replies: 1
    Last Post: 04-22-2012, 08:41 PM
  5. Can I create something like this?
    By Corinthian in forum Application Server Version 10 - Web/Browser Applications
    Replies: 9
    Last Post: 11-17-2010, 11:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •