Jump to content

Html-Imager Update of 17 Dec 2014


wakillon
 Share

Recommended Posts

2016020320555060os6.jpg

A simple script for generate a Html file with Images and some few features.

As usual external files and includes are embedded.

Compatible with AutoIt Versions 3.3.8.1 to 3.3.13.19

ChangeLog v 1.0.1.3

You can now Add/Manage Prev/Next/Home/Top/Bottom Page Links from Gui Menu.

 

Previous downloads : 111

Downloads available in the download section

 

Hope this example can be useful to someone !  :)

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

  • Moderators

Heya wakillon, any chance you could post the code without stripping it down? (with just the includes)

That makes for a lot of code to look through.

Edit:

This is just a request, no have toos!

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Thanks, I'll dig through that "short" ;) code in a bit :).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I selected a folder with 980 pictures and it took several minutes to load all those pictures.

  1. Can you try to speed it up?
  2. An abort feature would be great
  3. Double click on a picture will open the picture in e.g. default app or you display it
  4. How about a cool JS About intro? ;)

The last 4 pictures have no preview image in listview.

 

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I selected a folder with 980 pictures and it took several minutes to load all those pictures.

  1. Can you try to speed it up?
  2. An abort feature would be great
  3. Double click on a picture will open the picture in e.g. default app or you display it
  4. How about a cool JS About intro? ;)

The last 4 pictures have no preview image in listview.

 

Br,

UEZ

 

Hi UEZ !

1 no cause cpu usage will be too high

2 yes it can be added

3 yes it can be added too

4 What's that "JS About intro" ?

Thumbs in listview are loaded in memory for be resized with GDI functions, so may be the images count you have tried to load is a bit excessive... :P

Take a look to your CPU usage at the same time...

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Hi UEZ !

1 no cause cpu usage will be too high

2 yes it can be added

3 yes it can be added too

4 What's that "JS About intro" ?

Thumbs in listview are loaded in memory for be resized with GDI functions, so may be the images count you have tried to load is a bit excessive... :P

Take a look to your CPU usage at the same time...

 

Regarding 1 (never say never ;)):

I reduced the time from 166s to 66s using this modification of the function _GUICtrlListView_AdaptImage():

Func _GUICtrlListView_AdaptImage ( $hListView, $hImageList, $iIndex, $sFilePath, $iImageSize=128 )
    If Not FileExists ( $sFilePath ) Then Return SetError ( 1, 0, 0 )
    Local $hBitmap = _GDIPlus_BitmapCreateFromFile ( $sFilePath )
    Local $iNewWidth, $iNewHeight, $hBitmap_Scaled1, $hBitmap_Scaled2, $hGraphic, $iRatio
    Local $iWidth = _GDIPlus_ImageGetWidth ( $hBitmap )
    Local $iHeight = _GDIPlus_ImageGetHeight ( $hBitmap )
    ; keep ratio.
    If $iWidth >= $iHeight Then ; square or horizontal image.
        $iRatio = $iHeight/$iWidth
        $iNewWidth = $iImageSize
        $iNewHeight = Int ( $iImageSize * $iRatio )
    Else ; vertical image.
        $iRatio = $iWidth/$iHeight
        $iNewWidth = Int ( $iImageSize * $iRatio )
        $iNewHeight = $iImageSize
    EndIf
    $hBitmap_Scaled2 = _GDIPlus_BitmapCreateFromScan0($iImageSize, $iImageSize) ; _GDIPlus_ImageResizeEx ( $hBitmap, $iImageSize, $iImageSize )
    $hGraphic = _GDIPlus_ImageGetGraphicsContext ( $hBitmap_Scaled2 )
    _GDIPlus_GraphicsDrawImageRectRect ( $hGraphic, $hBitmap, _
        0, _
        0, _
        $iWidth, _
        $iHeight, _
        0, _
        0, _
        $iNewWidth, _
        $iNewHeight )
    Local $hImageBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap ( $hBitmap_Scaled2 )
    _GUIImageList_Add ( $hImageList, $hImageBMP )
    _WinAPI_DeleteObject ( $hImageBMP )
    _GDIPlus_GraphicsDispose ( $hGraphic )
    _GDIPlus_BitmapDispose ( $hBitmap_Scaled2 )
    _GDIPlus_BitmapDispose ( $hBitmap )
    _GUICtrlListView_AddItem ( $hListView, '', $iIndex )
EndFunc ;==> _GUICtrlListView_AdaptImage()

and removed the Sleep(10) from some of the functions.

 

Regarding 4:

You create a html for your About section. It would be cool to add some JavaScript effects, at least I would do it.  :D

 

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

wakillon

Good work, thanks for sharing.

 

mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

Thanks for sharing!

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

UEZ 

1) You have not understood all the utility of this function

it allows to create a thumbnails, yes , but it also allows this thumbnails to be displayed centered in his listview item.
Your modifications remove this functionality ! 
 
Why do you think i have added some "Sleep(10)" in each loops ?
 
I have tried with 1520 images in 178 sec ( so it need 0,11 sec for create each thumbnails)
CPU was about 20% and memory consumption was about 210000 K
So, It's already high !
If i remove all the "Sleep(10)", and test in the same conditions, yes it's a bit more fast, but my CPU rises above 25%
 
Increase the speed of execution is a good thing in itself, but you need to count the resources used too!  ;)
(am I speaking as an ecologist ?  :D)
 
4) Working on this script about HTML, I thought it was tasteful to have an "About" in HTML too, but my knowledges about it, is limited !  :P
But you know that javascript is not my cup of tea and I seem to remember that it was your case too ! no ?  :)
 
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

I didn't catch the center feature but that shouldn't hard to add:

Func _GUICtrlListView_AdaptImage ( $hListView, $hImageList, $iIndex, $sFilePath, $iImageSize=128 )
    If Not FileExists ( $sFilePath ) Then Return SetError ( 1, 0, 0 )
    Local $hBitmap = _GDIPlus_BitmapCreateFromFile ( $sFilePath )
    Local $iNewWidth, $iNewHeight, $hBitmap_Scaled1, $hBitmap_Scaled2, $hGraphic, $iRatio
    Local $iWidth = _GDIPlus_ImageGetWidth ( $hBitmap )
    Local $iHeight = _GDIPlus_ImageGetHeight ( $hBitmap )
    ; keep ratio.
    If $iWidth >= $iHeight Then ; square or horizontal image.
        $iRatio = $iHeight/$iWidth
        $iNewWidth = $iImageSize
        $iNewHeight = Int ( $iImageSize * $iRatio )
    Else ; vertical image.
        $iRatio = $iWidth/$iHeight
        $iNewWidth = Int ( $iImageSize * $iRatio )
        $iNewHeight = $iImageSize
    EndIf
    $hBitmap_Scaled2 = _GDIPlus_BitmapCreateFromScan0($iImageSize, $iImageSize) ; _GDIPlus_ImageResizeEx ( $hBitmap, $iImageSize, $iImageSize )
    $hGraphic = _GDIPlus_ImageGetGraphicsContext ( $hBitmap_Scaled2 )
    If $iWidth < $iImageSize And $iHeight < $iImageSize Then
        _GDIPlus_GraphicsDrawImageRect( $hGraphic, $hBitmap, ($iImageSize - $iWidth) / 2, ($iImageSize - $iHeight) / 2, $iWidth, $iHeight)
    Else
        _GDIPlus_GraphicsDrawImageRectRect ( $hGraphic, $hBitmap, _
            0, _
            0, _
            $iWidth, _
            $iHeight, _
            ($iImageSize - $iNewWidth) / 2, _
            ($iImageSize - $iNewHeight) / 2, _
            $iNewWidth, _
            $iNewHeight )
    EndIf
    Local $hImageBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap ( $hBitmap_Scaled2 )
    _GUIImageList_Add ( $hImageList, $hImageBMP )
    _WinAPI_DeleteObject ( $hImageBMP )
    _GDIPlus_GraphicsDispose ( $hGraphic )
    _GDIPlus_BitmapDispose ( $hBitmap_Scaled2 )
    _GDIPlus_BitmapDispose ( $hBitmap )
    _GUICtrlListView_AddItem ( $hListView, '', $iIndex )
EndFunc ;==> _GUICtrlListView_AdaptImage()

Imho, it doesn't matter whether the CPU usage is at 25% or 20% because it is for a limited of a time.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Imho, it doesn't matter whether the CPU usage is at 25% or 20% because it is for a limited of a time.

 

Depends if you are doing something else at the same time...

Your last modification is better, but do i need to consider that your new _GDIPlus_ImageResize function is too slow ?  :D

And for javascript all i have made is >here (be patient it's a bit slow to start)

:)

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Well, when you call _GDIPlus_GraphicsDrawImageRect* twice or more times it is slower than when you call it only once regardless whether _GDIPlus_GraphicsDrawImageRect* are slow functions...

Regarding the CPU usage. 25% usage means you have 4 cores and one is busy with you script. The other 3 cores are idle and waiting for some "work".

If you need some cool JS stuff have a look here: http://js1k.com/

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

The counting of the images seems not to work properly. After all 979 images are loaded the "current selection" is 1/979 although all thumbs are selected (as seen on your screenshot).

Selecting / unselecting count seems also not to work.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

The counting of the images seems not to work properly. After all 979 images are loaded the "current selection" is 1/979 although all thumbs are selected.

Selecting / unselecting count seems also not to work.

Br,

UEZ

 

I just load 1520 images without any problems

And multi select should not be possible as listview use $LVS_SINGLESEL style.

I can't reproduce your error...

Edit : if there is no selection, the selection label is empty. 

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Ok, I understood the "Current Selection" differently. I thought it is the count of all checked thumbs but it shows the position of the current selection only.

Sorry.

The JS (rotating balls) is very nice  :thumbsup: . Can you bring them behind the text?

Br,
UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...