It is currently Tue Jul 02, 2024 3:20 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Zoom
PostPosted: Wed Jul 28, 2021 2:23 pm  (#1) 
Offline
GimpChat Member
User avatar

Joined: Mar 27, 2015
Posts: 22
Hi all,

anybody know a script-fu way to set the zoom of an image to 100% ?

Thanks


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Zoom
PostPosted: Wed Jul 28, 2021 8:46 pm  (#2) 
Offline
GimpChat Member
User avatar

Joined: May 24, 2021
Posts: 790
Location: SEA - South East Asia
Is it to write a script?

If not -> Just hit the 1 key on your keyboard = 100%
2 = 200%
3 = 400%
and so

Ctrl +Shift + J = fit canvas

_________________
Patrice


Top
 Post subject: Re: Zoom
PostPosted: Thu Jul 29, 2021 1:52 am  (#3) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4752
Sweeney wrote:
Hi all,

anybody know a script-fu way to set the zoom of an image to 100% ?

Thanks


There is none, by design, scripts cannot interact with the UI. But the shortcut to "View->100%" is "1".

_________________
Image


Top
 Post subject: Driving Gimp's GUI with PowerShell
PostPosted: Fri Nov 05, 2021 3:26 pm  (#4) 
Offline
GimpChat Member
User avatar

Joined: Oct 23, 2021
Posts: 67
Hello Sweeney,

1. Run :bowdown PowerShell

Click Windows "Start" > Windows "PowerShell" or "Windows PowerShell ISE"

Before running any PowerShell script, give the following permission one time per session:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process

Copy in the clipboard the above PowerShell command by Ctrl+C.
Then paste it by Ctrl+V in the PowerShell console or the Windows ISE running console.
Don't forget to validate this command by pressing the "ENTER" key in the console.

Dlgbox "Execution Policy Change":
Windows PowerShell wrote:
The execution policy helps protect you from scripts that you do not trust.
Changing the execution policy might expose you to the security risks described in the about_Execution_Policies help topic at https:/go.microsoft.com/fwlink/?LinkID=135170.
Do you want to change the execution policy?

Click Yes
The change of policy is enabled only during the current session.
If you close Windows ISE or the PowerShell console, the protective policy is again applied.
Remember that the (pre-)historic :shoot MS/DOS :pound console did not have this kind of policy.


2. Run Gimp

Click Windows "Start" > Gimp 2.10.28
Reorganize the Gimp window and the PowerShell ISE or PowerShell console side-by-side in order to see the result of the PowerShell command on Gimp.
Do not overlap the PowerShell console window above the Gimp window.

Gimp menu "File" > "Open" your preferred image you wish to zoom.

Be sure that the zoom is at for example 200%:
Gimp menu "View" > "Zoom" > 2:1 (200%)
or press the shortcut "2" just after the loading of your picture.


3. Define GimpZoom

Copy by Ctrl+C the following PowerShell script defining the function GimpZoom:
function GimpZoom
{
    param   (
        [parameter(Position=0)][int]$level = 100
            )
    process
    {
        $wsh = New-Object -ComObject WScript.Shell
        $wsh.AppActivate((Get-Process gimp-2.10).Id)   
        start-sleep -Milliseconds 500
        switch ($level)
        {
           1600     {$key = "5" ; Break} # 1600%
            800     {$key = "4" ; Break} #  800%
            400     {$key = "3" ; Break} #  400%
            200     {$key = "2" ; Break} #  200%
             50     {$key = "6" ; Break} #   50%
            default {$key = "1" ; Break} #  100%
        }
        if ($key.Length -gt 0) {$wsh.SendKeys($key)}
        Write-Host "key = $key"
    }
}

The script retrieves the ID of the Gimp 2.10 process.
Then it sends the wished shortcut according to the level parameter.
The COM application is named Windows Script Host (WSH) available in each standard Windows.

Paste by Ctrl+V the content of the clipboard in the PowerShell ISE editor or the PowerShell console:
In the PowerShell IDE, click Run (F5) to define the function GimpZoom.
In the PowerShell console, after the paste, the function GimpZoom is defined.


4. Call GimpZoom

Copy and paste the call of the function with as level parameter the integer 100 meaning 100%: :keybdtype
GimpZoom -level 100

Do not enter the "%" symbol. :nono

When you validate the call of the function by "ENTER"
the GIMP zoom is set to 100% as required. :geek:

Note: if you wish to reduce the zoom to 50%, the default shortcut "Shift+2" :roll: is too difficult to simulate.
Normally Shift is coded by "+" but on QWERTY keyboard even if the key "2" is directly available,
Shift+2 would generate another character that Gimp does not understand.

That is why it is suggested to replace the Shift+N shortcuts with direct simpler integers such as 6 to 8.
0 and 9 are already used.
That is why for the -level 50, the shortcut 6 is simulated.


5. Define and call GimpZoomLoop :hexer

Finally, optionally copy and paste GimpZoomLoop.
function GimpZoomLoop()
{
    for ($level = 100; $level -le 1600; $level *= 2)
    {
        GimpZoom -level $level
        start-sleep -Seconds 1
    }
    for ($level = 1600; $level -ge 100; $level /= 2)
    {
        GimpZoom -level $level
        start-sleep -Seconds 1
    }
}

This function calls GimpZoom with level from 100% to 1600% then from 1600% to 100% :wh
sleeping 1 second between two calls.


6. Conclusion about automation testing via the GUI

The PowerShell script GimpZoom does not know when the operation of change of the Gimp zoom is really over.
We need to sleep :zzz during a tempo that you could need to adapt according to the power of your PC.

Driving the Gimp's GUI is strongly dependent on:
  • the Operating System, Windows;
  • the Gimp's shortcut and language;
  • the language of the keyboard;
  • the power of the PC about each tempo.

Synchronizing automatically the PowerShell script with Gimp :hugme is out of the scope of this article. :bawl
For example, reading that the GUI changed
in order to be sure that the current operation is over :rofl
before sending another keystroke. :lmao

For more information, search free tools for automation testing.


Top
 Post subject: Re: Zoom
PostPosted: Fri Nov 05, 2021 5:58 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: Nov 04, 2015
Posts: 1365
You're out of luck. Can't use Gimp to do zooms.


Image


Top
 Post subject: Infinite Zoom
PostPosted: Sat Nov 06, 2021 6:06 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Oct 23, 2021
Posts: 67
Tas_mania, I cannot compete with your Infinite Zoom! :jumpclap


Top
 Post subject: Re: Zoom
PostPosted: Sun Nov 07, 2021 10:52 pm  (#7) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12531
That is a cool effect, Tas. :)

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: Zoom
PostPosted: Sun Nov 07, 2021 11:43 pm  (#8) 
Offline
GimpChat Member
User avatar

Joined: Nov 04, 2015
Posts: 1365
eh, eh the zoom only has 6 frames. Done with G'MIC zoom and a batch script I made for the command line version of G'MIC.


Top
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) My First Infinite Zoom In Gimp

20

No new posts Animation playback zoom

3

No new posts Attachment(s) Help with Unified tool when ZOOM in SOLVED !!

6

No new posts Attachment(s) Initial Zoom Ratio = Show entire image?

4

No new posts [SOLVED]Does GIMP [2.10] have a "zoom to layer" function?

9



* Login  



Powered by phpBB3 © phpBB Group