Also for Image

Also for Image

Postby Silvio.Falconi » Sat Oct 05, 2013 9:07 am

I found on freemage documentation other nformat for save an image
Code: Select all  Expand view  RUN
# define FIF_BMP         0
# define FIF_ICO         1
# define FIF_JPEG        2
# define FIF_JNG         3
# define FIF_KOALA       4
# define FIF_LBM         5
# define FIF_IFF         5
# define FIF_MNG         6
# define FIF_PBM         7
# define FIF_PBMRAW      8
# define FIF_PCD         9
# define FIF_PCX        10
# define FIF_PGM        11
# define FIF_PGMRAW     12
# define FIF_PNG        13
# define FIF_PPM        14
# define FIF_PPMRAW     15
# define FIF_RAS        16
# define FIF_TARGA      17
# define FIF_TIFF       18
# define FIF_WBMP       19
# define FIF_PSD        20
# define FIF_CUT        21
# define FIF_XBM        22
# define FIF_XPM        23
# define FIF_DDS        24

 



Someone has experiences with save of these formats ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: Also for Image

Postby ukoenig » Sat Oct 05, 2013 9:33 am

Silvio,
did You test this ?

viewtopic.php?f=3&t=22254&p=118453&hilit=image+converter#p118453

NCONVERT
========
Nconvert is the multi-format commandline image converter for Win32, DOS, OS/2, and other platforms.
Type "nconvert -help" for available options.
Type "nconvert -help > nchelp.txt" to save the help text into the file "nchelp.txt".
To convert files to a specific format, type for example :
nconvert -out 5 file1.pic file2.jpg file3.tga
or
nconvert -out tiff file1.pic file2.jpg file3.tga

With a resize :
nconvert -out jpeg -ratio -resize 480 0 *.jpg
nconvert -out jpeg -resize 640 480 *.jpg

The input format is not necessary, it will be autodetected. If a problem occurs, use the -in option.

Nconvert is able to transform images while converting:
* To convert GIF files to JPEG files :
nconvert -out jpeg -truecolors *.gif

* To convert JPEG files to GIF files :
nconvert -out gif -dither -colors 256 *.jpeg

* To resize :
nconvert -out png -resize 510 230 *.jpeg
nconvert -out png -ratio -resize 510 0 *.jpeg
nconvert -out png -ratio -resize 0 510 *.jpeg
nconvert -out png -resize 200% 200% *.jpeg

You can use it with images sequences.
For example, to convert the files file00.pic, file01.pic, ..., file10.pic and
we convert to jpeg format with the name pattern res0.jpg, res1.jpg, ... type :
nconvert -out jpeg -n 1 10 1 -o res#.jpg file##.pic

You can use % to specify source filename in dest filename.
For example, nconvert -out jpeg -o result_%.jpg file.tga
creates a file named result_file.jpg

Note for windows users: in batch files you must write %% instead of %. To bypass this problem, you can use a nconvert script instead of a batch file.

You can control nconvert with a script, performing multiple sets of conversions on multiple sets of files, example:

### -out png -rtype lanczos -resize 200% 150%

screenshot1.bmp
screenshot2.bmp
screenshot3.bmp

### -out gif -rtype lanczos -resize 500% 500% -oil 10 -colours 32

F:\icons\smile.bmp

### -out bmp -rtype lanczos -resize 30% 30% -oil 2 -rotate_flag smooth -rotate 45

selfportrait.png
mydog.png

Save this into a text file, for example "nc.txt", and then run nconvert with this file as the only parameter: "nconvert nc.txt" .

Limitations:

Add text feature uses the Win32 API and is avaiable on Win32 only.
Some exotical image formats use external DLL's and are available on Win32 only.
When using a script file, avoid multiple spaces in the conversion definitions, they confuse the parser.
Converting huge images, or scaling up to a huge size requires much memory and may not always work.

The convert section from the tool :

Code: Select all  Expand view  RUN

FUNCTION MAKE_FILE()

cStyle := "Image FORMAT"

// cOrgFile := cNewBITM, ;                 
// cWorkfile := c_path  + "\Images\" + cOnlyName + "_P." + cExtension
// cNewfile := c_path + "\Images\_" + cOnlyName + "." + cExpExten

// NConvert -o E:\T_NCONVERT\Images\_OLGA.DIB -out dib -overwrite E:\T_NCONVERT\Images\OLGA.JPG
// NConvert -o E:\T_NCONVERT\Images\_OLGA.PDF -out pdf -overwrite E:\T_NCONVERT\Images\OLGA.JPG

IF LOWER(cFileExt( cWorkfile )) <> LOWER(cExpExten)
    IF FILE( cWorkfile )
           cNewfile := c_path + "\Images\" + cOnlyName + "_F." + cExtension
           cScript1 := '-quiet -o ' + cNewfile + ' -out ' + LOWER(cExpExten) + ' -overwrite ' + cWorkfile
       
        cScript := "
// Format-Convert SCRIPT" + CRLF + CRLF + ;
               "cIN_File := " + cWorkfile + CRLF + ;
               "cOUT_File := " + cNewfile + CRLF + CRLF + ;
               'cScript := " -quiet -o " + cOUT_File + " -out ' + LOWER(cExpExten) + ' -overwrite " + cIN_File' + CRLF + CRLF + ;
               'WAITRUN ( "NConvert " + cScript, 0 )'

        WAITRUN ( "NConvert " + cScript1, 0 )

        IF FILE( cNewfile )
            SAVE_IMAGE()
        ELSE
            MsgAlert( "The File : " + CRLF + ;
                       cNewfile + CRLF + ; 
                       "is not created !!!", "ERROR")
        ENDIF
    ENDIF
ELSE
    MsgAlert( "Export to same Format : " + cExtension + CRLF + ;
                    "not possible !", "Export-Error" )

ENDIF

RETURN ( NIL )
 


Best Regards
Uwe :?:
Last edited by ukoenig on Sat Oct 05, 2013 9:52 am, edited 2 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Also for Image

Postby Silvio.Falconi » Sat Oct 05, 2013 9:47 am

Sorry Uwe ,
I wish use FreeImage.dll and not Nconverte.exe ( it is to big on memory)
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: Also for Image

Postby MaxP » Mon Oct 07, 2013 6:16 am

use this method

Code: Select all  Expand view  RUN

    METHOD SaveImage( cFile, nFormat, nQuality ) CLASS TImage
 


example

Code: Select all  Expand view  RUN

    oImg:SaveImage( "test.pcx", FIF_PCX )

     oImg:SaveImage( "test.png", FIF_PNG )

     oImg:SaveImage( "test.jpg", FIF_JPEG )
 


etc.

Massimo
User avatar
MaxP
 
Posts: 88
Joined: Thu Jul 12, 2007 2:02 pm

Re: Also for Image

Postby Silvio.Falconi » Tue Nov 12, 2013 8:33 am

How save a image on the extension seletected from finale user

local cFile := cGetFile( "Bitmap (*.bmp)| *.bmp|" + ;
"DIB (*.dib)| *.dib|" + ;
"PCX (*.pcx)| *.pcx|" + ;
"JPEG (*.jpg)| *.jpg|" + ;
"GIF (*.gif)| *.gif|" + ;
"TARGA (*.tga)| *.tga|" + ;
"RLE (*.rle)| *.rle|" + ;
"All Files (*.*)| *.*" ;
,"Save as", CurDir(), .t. )


nFormat:=
nFlag := 25


oImage:SaveImage( cFile, nFormat, nFlag )
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: Also for Image

Postby ukoenig » Tue Nov 12, 2013 10:10 am

SIlvio,

my ALL-IN-ONE-solution : RESIZE + EXPORT :
I'm working only with filenames and call the images like :

c_path := cFilePath(GetModuleFileName( GetInstance() ) )
c_path1 := c_path + "IMAGES\"
FILENAME => c_path1 + "_Olga.Bmp"

from Section Imageselect :

Image

The STARTSCREEN

Image

Preview of Original-size and format (a JPG selected in section Imageselect)
( select any Window-background )

Image

Preview of Original resized to double-size (a JPG selected in section Imageselect)

Image

Preview of the Result of resized and exported image (BMP-format defined in section Imageselect)

Image

Best regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 85 guests