Find out the position in an image
Moderator: Kathy_9
-
psphufi
- Posts: 69
- Joined: Wed Nov 02, 2016 7:41 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- ram: 128 GB
- Hard_Drive_Capacity: 1 TB
- Corel programs: PSP X9, PSP 2018
- Location: Germany
Find out the position in an image
Hello,
I wish to find out a position within an image. For example there is a tower and will know the coordinates in top% and left%.
Is this possible?
Thank you!
I wish to find out a position within an image. For example there is a tower and will know the coordinates in top% and left%.
Is this possible?
Thank you!
-
LeviFiction
- Advisor
- Posts: 6831
- Joined: Thu Oct 02, 2008 1:07 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Alienware M17xR4
- processor: Intel Core i7-3630QM CPU - 2_40GH
- ram: 6 GB
- Video Card: NVIDIA GeForce GTX 660M
- sound_card: Sound Blaster Recon3Di
- Hard_Drive_Capacity: 500GB
- Corel programs: PSP: 8-2023
- Location: USA
Re: Find out the position in an image
There are several options, the easiest is to position your mouse cursor where you think the top is and then look at the status bar at the bottom of the program. It should show you the location in pixels of the cursor. It'll be in the bottom right-hand corner. Should look something like this
(x:###,y:###) - (R: ###, G: ###, B: ###, O: ###) -- Image: width x height - bit depth
X and Y are the position of your mouse.
You can also use the pick tool to move the "pivot" point and then look at the tool options to see at what location you placed the pivot. So with the pick tool active you make sure you have a layer selected, you should see a pivot point in the middle of the layer. While holding CTRL click in the pivot point and drag it to a new location. now look a the tool options palette under "Pivot" you'll see the current X and Y location.
(x:###,y:###) - (R: ###, G: ###, B: ###, O: ###) -- Image: width x height - bit depth
X and Y are the position of your mouse.
You can also use the pick tool to move the "pivot" point and then look at the tool options to see at what location you placed the pivot. So with the pick tool active you make sure you have a layer selected, you should see a pivot point in the middle of the layer. While holding CTRL click in the pivot point and drag it to a new location. now look a the tool options palette under "Pivot" you'll see the current X and Y location.
https://levifiction.wordpress.com/
-
psphufi
- Posts: 69
- Joined: Wed Nov 02, 2016 7:41 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- ram: 128 GB
- Hard_Drive_Capacity: 1 TB
- Corel programs: PSP X9, PSP 2018
- Location: Germany
Re: Find out the position in an image
Thanks for your answer!
But this is not the way I am searching for: I got a CSS and HTML-Code which places hotspots to show tooltips, and the code needs the position in percent top and percent left as you see here:
<div class="HotSpot bullet" style="top: 63%; left: 65%;">
So I have to to look for another way...
Have a good time!
Norbert
But this is not the way I am searching for: I got a CSS and HTML-Code which places hotspots to show tooltips, and the code needs the position in percent top and percent left as you see here:
<div class="HotSpot bullet" style="top: 63%; left: 65%;">
So I have to to look for another way...
Have a good time!
Norbert
-
LeviFiction
- Advisor
- Posts: 6831
- Joined: Thu Oct 02, 2008 1:07 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Alienware M17xR4
- processor: Intel Core i7-3630QM CPU - 2_40GH
- ram: 6 GB
- Video Card: NVIDIA GeForce GTX 660M
- sound_card: Sound Blaster Recon3Di
- Hard_Drive_Capacity: 500GB
- Corel programs: PSP: 8-2023
- Location: USA
Re: Find out the position in an image
No, you just need to know math.
Seriously, if you know how large your image is, and you know where a location is in pixels. It's simple math to get the percentage. I imagine you want to use percentages because the site is responsive.
So let's assume that you have an image that's 1440x625 pixels in size. You know the point you want is located at x:325, y:250. 325/1440 = .225 or 22.5%. You can found up or down. 250/625 = .4 = 40%. So your location is top:22%; left: 40%;
It would be easy enough to create a small script that will grab a corner of something and then give you the percentages if you want. A script would work like this, you create a rectangle selection starting where the div should start, then run the script. The script will take the top and left coordinates and do the simple math, returning the percentages to the script-output palette. Which would you prefer, manual math, or a script?
Seriously, if you know how large your image is, and you know where a location is in pixels. It's simple math to get the percentage. I imagine you want to use percentages because the site is responsive.
So let's assume that you have an image that's 1440x625 pixels in size. You know the point you want is located at x:325, y:250. 325/1440 = .225 or 22.5%. You can found up or down. 250/625 = .4 = 40%. So your location is top:22%; left: 40%;
It would be easy enough to create a small script that will grab a corner of something and then give you the percentages if you want. A script would work like this, you create a rectangle selection starting where the div should start, then run the script. The script will take the top and left coordinates and do the simple math, returning the percentages to the script-output palette. Which would you prefer, manual math, or a script?
https://levifiction.wordpress.com/
-
psphufi
- Posts: 69
- Joined: Wed Nov 02, 2016 7:41 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- ram: 128 GB
- Hard_Drive_Capacity: 1 TB
- Corel programs: PSP X9, PSP 2018
- Location: Germany
Re: Find out the position in an image
Math is not the thing I loved in my schooltime... 
-
psphufi
- Posts: 69
- Joined: Wed Nov 02, 2016 7:41 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- ram: 128 GB
- Hard_Drive_Capacity: 1 TB
- Corel programs: PSP X9, PSP 2018
- Location: Germany
Re: Find out the position in an image
I cannot create such a script... 
-
LeviFiction
- Advisor
- Posts: 6831
- Joined: Thu Oct 02, 2008 1:07 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Alienware M17xR4
- processor: Intel Core i7-3630QM CPU - 2_40GH
- ram: 6 GB
- Video Card: NVIDIA GeForce GTX 660M
- sound_card: Sound Blaster Recon3Di
- Hard_Drive_Capacity: 500GB
- Corel programs: PSP: 8-2023
- Location: USA
Re: Find out the position in an image
Didn't say you could, while I admit I didn't make it clear I was offering to make such a script. But I wasn't going to unless you asked.
I've attached the script
Video demo: https://drive.google.com/file/d/1jgzy34 ... e7aIb/view
I've attached the script
Video demo: https://drive.google.com/file/d/1jgzy34 ... e7aIb/view
- Attachments
-
- position-script.zip
- (436 Bytes) Downloaded 132 times
https://levifiction.wordpress.com/
- Ken Berry
- Site Admin
- Posts: 22481
- Joined: Fri Dec 10, 2004 9:36 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Gigabyte B550M DS3H AC
- processor: AMD Ryzen 9 5900X
- ram: 32 GB DDR4
- Video Card: AMD RX 6600 XT
- Hard_Drive_Capacity: 1 TB SSD + 2 TB HDD
- Monitor/Display Make & Model: Kogan 32" 4K 3840 x 2160
- Corel programs: VS2022; PSP2023; DRAW2021; Painter 2022
- Location: Levin, New Zealand
Re: Find out the position in an image
To keep JoeB happy, and to keep things tidy, I have copied this thread into the PSP Scripting forum. If there are further questions about the script Levi Fiction has kindly provided, I suggest discussion continue in the other forum.
Ken Berry
-
LeviFiction
- Advisor
- Posts: 6831
- Joined: Thu Oct 02, 2008 1:07 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Alienware M17xR4
- processor: Intel Core i7-3630QM CPU - 2_40GH
- ram: 6 GB
- Video Card: NVIDIA GeForce GTX 660M
- sound_card: Sound Blaster Recon3Di
- Hard_Drive_Capacity: 500GB
- Corel programs: PSP: 8-2023
- Location: USA
Re: Find out the position in an image
Not to question you there Ken, but although I added a script the topic itself is on how to find a position inside the image. The script is a secondary thing. It wasn't what they specifically were aiming for when they asked the question.
Should I only place a script in the scripting sub-forum and link to another topic if a similar situation comes up again?
Should I only place a script in the scripting sub-forum and link to another topic if a similar situation comes up again?
https://levifiction.wordpress.com/
- Ken Berry
- Site Admin
- Posts: 22481
- Joined: Fri Dec 10, 2004 9:36 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Gigabyte B550M DS3H AC
- processor: AMD Ryzen 9 5900X
- ram: 32 GB DDR4
- Video Card: AMD RX 6600 XT
- Hard_Drive_Capacity: 1 TB SSD + 2 TB HDD
- Monitor/Display Make & Model: Kogan 32" 4K 3840 x 2160
- Corel programs: VS2022; PSP2023; DRAW2021; Painter 2022
- Location: Levin, New Zealand
Re: Find out the position in an image
Copying the topic to another forum of course does not affect its position in this forum, so discussion of positioning can continue here. But if there is substantive discussion of the script, I think that would best occur in the Scripting forum.
I don't think you need to post scripts *only* in the Scripting forum, but you could copy it there with perhaps a brief explanation and link to this forum.
I don't think you need to post scripts *only* in the Scripting forum, but you could copy it there with perhaps a brief explanation and link to this forum.
Ken Berry
-
JoeB
- Posts: 2778
- Joined: Fri Mar 28, 2008 10:04 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: LENOVO 4524PE4 ThinkCentre M91p
- processor: 3.10 gigahertz Intel Quad Core i5-2400
- ram: 8 GB
- Hard_Drive_Capacity: 4.6 TB
- Corel programs: PSP 9, X7 to 2019, 32 & 64-bit
- Location: Canada
Re: Find out the position in an image
While of course it's really not up to me
I tend to agree with Ken. My last scripting thing started with a post that wasn't about scripts either but I realized that the discussion - and perhaps the script itself - could be useful to others, and having a copy of the thread in the Scripting sub-forum would make it available to those who were only searching for scripts - and they might not search for scripts in this forum.
And it's not like everyone who visits the scripting forum are looking for a particular script. I suspect that many, many visitors to that sub-forum are just browsing first, and then they come across something they hadn't previously realized might be useful for them and then download it after reading the thread. That's why I initially asked Ken to set up that sub-forum. I was trying to browse for scripts that I might find useful in this forum and it was a herculean task.
So I set about searching for and finding everything I could find about scripts in this forum and Ken used and copied those threads to set up the Scripting sub-forum. And it's much easier now for everyone specifically looking for scripts or scripting info to be able to browse and find scripts or info all in one place - with much fewer posts to browse - whether or not if might also appear in this main forum, and whether it's something specific they need or they're just browsing and might find something that suddenly looks useful for them.
So I hope that, when scripts are posted here, Ken will continue to make them available in the Scripting sub-forum as a copy of the thread here. And if it's a thread that might have continuing discussion after it's copied, perhaps the last poster - or Ken himself - could post a message when the script has been copied stating that it has been copied to scripting and perhaps those who wish to follow or continue with the discussion could do so there - and of course provide the link to that topic. I did that when he copied my last thread there. The link to my notice in that thread is http://forum.corel.com/EN/viewtopic.php ... 75#p351675 .
But yes, no reason that a script can't be posted here IMHO, particularly if the thread started out as a non-script thread. I just think it's a good idea also to make any and all information relating to scripts - and all scripts - available in the Scripting forum to make that sub-forum and its resources as useful and complete as possible.
And it's not like everyone who visits the scripting forum are looking for a particular script. I suspect that many, many visitors to that sub-forum are just browsing first, and then they come across something they hadn't previously realized might be useful for them and then download it after reading the thread. That's why I initially asked Ken to set up that sub-forum. I was trying to browse for scripts that I might find useful in this forum and it was a herculean task.
So I set about searching for and finding everything I could find about scripts in this forum and Ken used and copied those threads to set up the Scripting sub-forum. And it's much easier now for everyone specifically looking for scripts or scripting info to be able to browse and find scripts or info all in one place - with much fewer posts to browse - whether or not if might also appear in this main forum, and whether it's something specific they need or they're just browsing and might find something that suddenly looks useful for them.
So I hope that, when scripts are posted here, Ken will continue to make them available in the Scripting sub-forum as a copy of the thread here. And if it's a thread that might have continuing discussion after it's copied, perhaps the last poster - or Ken himself - could post a message when the script has been copied stating that it has been copied to scripting and perhaps those who wish to follow or continue with the discussion could do so there - and of course provide the link to that topic. I did that when he copied my last thread there. The link to my notice in that thread is http://forum.corel.com/EN/viewtopic.php ... 75#p351675 .
But yes, no reason that a script can't be posted here IMHO, particularly if the thread started out as a non-script thread. I just think it's a good idea also to make any and all information relating to scripts - and all scripts - available in the Scripting forum to make that sub-forum and its resources as useful and complete as possible.
Regards,
JoeB
Using PSP 2019 64bit
JoeB
Using PSP 2019 64bit
-
psphufi
- Posts: 69
- Joined: Wed Nov 02, 2016 7:41 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- ram: 128 GB
- Hard_Drive_Capacity: 1 TB
- Corel programs: PSP X9, PSP 2018
- Location: Germany
Re: Find out the position in an image
I thought that this short answer was answer enough...LeviFiction wrote:Didn't say you could, while I admit I didn't make it clear I was offering to make such a script. But I wasn't going to unless you asked.
I've attached the script
Video demo: https://drive.google.com/file/d/1jgzy34 ... e7aIb/view
Thank you very much! This skript is really very fine and helpful! And the additional video: top!
Best regards
Norbert
