image dimensions
image dimensions
I haven't found a way. How to read the width and height of the image?
Re: image dimensions
image you mean a loaded brush ?
use GetAttribute()
use GetAttribute()
Code: Select all
LoadBrush(1,"c:\\23.png")
DebugPrint(GetAttribute(#BRUSH,1,#ATTRWIDTH))
DebugPrint(GetAttribute(#BRUSH,1,#ATTRHEIGHT))
Christos
Re: image dimensions
I'm thinking about a small program that manipulates photo dimensions and cropping. If using a brush is appropriate, then yes. I have no programming experience and I'm playing around with AI, but it's not quite right. After a long struggle, the AI also managed to get attributes, but I wasn't sure. Thank you.
Re: image dimensions
whats your logic?
how you plan to manipulate image ? you first have to load it correct?
but yes you cant find image size without loading it first
you can however examine image header, but is not that simple...
how you plan to manipulate image ? you first have to load it correct?
but yes you cant find image size without loading it first
you can however examine image header, but is not that simple...
Christos
Re: image dimensions
The program's logic is as follows:
1. Load the image and read the dimensions
2. Display the image
3. Apply a movable rectangle for cropping
4. Select the rectangle format: 3R, 4R, 5R, A5, A4
5. Select the rectangle's horizontal/vertical position
6. Scale the image under the rectangle
7. Crop the image using the rectangle/crop
8. Save the cropped image in PDF format
9. Simple printout using an external VPDF program
I'm afraid it's beyond me, even with AI
but it's fun.
1. Load the image and read the dimensions
2. Display the image
3. Apply a movable rectangle for cropping
4. Select the rectangle format: 3R, 4R, 5R, A5, A4
5. Select the rectangle's horizontal/vertical position
6. Scale the image under the rectangle
7. Crop the image using the rectangle/crop
8. Save the cropped image in PDF format
9. Simple printout using an external VPDF program
I'm afraid it's beyond me, even with AI
Re: image dimensions
well as for image size
you said
as for the complicated level, is not that complicated since you are using a veryhigh level languange and a layer (hollywood)
most probably the problem is that you rely heavy in AI and dont experiment your self
a few hours reading manual will help you build this app, is possible
at any case Goodluck withj your project
you said
after this which is obvious a LoadBrush() you can get image size1. Load the image and read the dimensions
as for the complicated level, is not that complicated since you are using a veryhigh level languange and a layer (hollywood)
most probably the problem is that you rely heavy in AI and dont experiment your self
a few hours reading manual will help you build this app, is possible
at any case Goodluck withj your project
Christos
Re: image dimensions
I postponed reading the image dimensions because adding this function would conflict with the image's current display method. For now, I've focused on displaying the image and overlaying a moveable rectangle over it. However, the rectangle won't move. Could someone take a look and tell me what needs to be done to make the rectangle moveable?
Code: Select all
@APPTITLE "Load JPG and Drag Rectangle"
@DISPLAY {Width=800, Height=600, Title="Load JPG and Drag Rectangle", Color=$FFFFFF}
; Global variables
Global original_image
Global rect_x = (800 - 400) / 2
Global rect_y = (600 - 300) / 2
Global is_dragging = False
Global drag_offset_x, drag_offset_y
; Function to draw the rectangle and handles
Function DrawRectangle()
If original_image
; Draw the red rectangle
Box(rect_x, rect_y, 400, 300, $FF0000, #FILLNONE)
; Draw handles at the corners of the rectangle
Box(rect_x - 5, rect_y - 5, 10, 10, $0000FF) ; Top-left handle
Box(rect_x + 400 - 5, rect_y - 5, 10, 10, $0000FF) ; Top-right handle
Box(rect_x - 5, rect_y + 300 - 5, 10, 10, $0000FF) ; Bottom-left handle
Box(rect_x + 400 - 5, rect_y + 300 - 5, 10, 10, $0000FF) ; Bottom-right handle
EndIf
EndFunction
; Function to start dragging the rectangle
Function StartDragging(x, y)
If x >= rect_x And x <= rect_x + 400 And y >= rect_y And y <= rect_y + 300
is_dragging = True
drag_offset_x = x - rect_x
drag_offset_y = y - rect_y
EndIf
EndFunction
; Function to drag the rectangle
Function DragRectangle(x, y)
If is_dragging
; Clear the old rectangle by redrawing the image
If original_image
DisplayBrush(original_image, 0, 0)
EndIf
; Update the rectangle position
rect_x = x - drag_offset_x
rect_y = y - drag_offset_y
; Draw the new rectangle
DrawRectangle()
EndIf
EndFunction
; Function to stop dragging the rectangle
Function StopDragging()
is_dragging = False
EndFunction
; Function to load an image via dialog
Function LoadImage()
Local file$
file$ = FileRequest("Select a JPG Image", "JPG Files|jpg", 0)
If file$
DebugPrint("Selected path: ", file$)
original_image = LoadBrush(Nil, file$)
If original_image
DisplayBrush(original_image, 0, 0)
DrawRectangle()
DebugPrint("JPG image loaded successfully.")
Else
DebugPrint("Failed to load JPG image.")
SystemRequest("Error", "Failed to load the JPG image.", "OK", #REQICON_ERROR)
EndIf
EndIf
EndFunction
; Function to handle image drop
Function p_DropFunc(msg)
original_image = LoadBrush(Nil, msg.DropFiles[0])
If original_image
DisplayBrush(original_image, 0, 0)
DrawRectangle()
DebugPrint("JPG image loaded successfully via drop.")
Else
DebugPrint("Failed to load the image.")
EndIf
EndFunction
; Function to handle mouse events
Function p_MouseFunc(msg)
If msg.action = "OnLeftDown"
StartDragging(msg.x, msg.y)
ElseIf msg.action = "OnLeftUp"
StopDragging()
ElseIf msg.action = "OnMouseMove"
DragRectangle(msg.x, msg.y)
EndIf
EndFunction
; Define the menu
@MENU 1, {
{"File", {
{"Load Image", ID = "load"},
{"Exit", ID = "quit"}
}}
}
; Assign the menu to the window
@DISPLAY {Menu = 1}
; Function to handle menu events
Function p_MenuFunc(msg)
If msg.action = "OnMenuSelect"
Switch msg.item
Case "load"
LoadImage()
Case "quit"
End
EndSwitch
EndIf
EndFunction
; Install event handlers
InstallEventHandler({
OnDropFile = p_DropFunc,
OnMenuSelect = p_MenuFunc,
OnLeftDown = p_MouseFunc,
OnLeftUp = p_MouseFunc,
OnMouseMove = p_MouseFunc
})
; Display instructions
TextOut(28, 28, "Drop an image here or use File -> Load Image")
TextOut(28, 44, "Click and drag to move the rectangle")
; Main program loop
Repeat
WaitEvent
Forever
Re: image dimensions
You are using wrong command.
It is not OnLeftDown, and OnLeftUp, but it is OnMouseDown and OnMouseUp.
Change those and it works.
It is not OnLeftDown, and OnLeftUp, but it is OnMouseDown and OnMouseUp.
Change those and it works.
Re: image dimensions
Thanks for your help, it actually works now. Now I'll move on to the next steps.