How to resize multiple images to the same size in draw

I have created an 156 pages file in draw by my self. When i was making it i thought it was the right size but now i change my mind, every page has 3-9 images in it, and i want all of them to have the same size but i don’t mind to keep the ratio so i was looking for something like pic tool but for draw, i can’t find the way to do it and im not very interested to change the pictures one by one neither to move my work to writer just for that.

Please upload a 3-4 page sample file here (to see the type and other properties of the graphics objects located in the file)

You can write a macro (you can not record it) for resize all the same type or similarly named graphic objects.

1 Like

https://drive.google.com/drive/folders/1KjQ__PWJfIDX-OJKRPu1BYTtP-Z6R4vu?usp=drive_link
that’s part of my file. I dint know how to write a macro not either how to record one. Why is that simple think so difficult?

There is an other one reason that is not very possible to work with other programs some parts of my file was in a pdf at first and a lot of people don’t seem to understand that something like draw is the easy way to process and combine those parts of files.

You can not Record a Draw related macro, because the Macro recorder works in the Calc and in the Writer applications only. And the recording the macros is not an effective mode of the macro creation.

Here is a macro snippet:

REM  *****  BASIC  *****
Option explicit 


Sub ResizeImages

 Dim oDrawDoc as object
 Dim oPages, oDrawPage as object
 Dim oShape as object
 Dim oSize as object
 Dim Ratio as double
 Dim iPageCount, iShapeCount, i, j as integer
 
 	oDrawDoc = Thiscomponent()
	oPages = oDrawDoc.GetDrawPages()
	iPageCount = oPages.GetCount() 
	For i = 0 to iPageCount-1
		oDrawPage = oDrawDoc.DrawPages(i)
		For j = 0 To oDrawPage.getCount()-1 
			oShape = oDrawPage.getByIndex(j)
			if oShape.supportsService("com.sun.star.drawing.GraphicObjectShape") then
				oSize = oShape.getSize()	
				Ratio = oSize.Height/oSize.Width
				oSize.Width = 6000 'in unit hundredths of a millimeter
				oSize.Height = int(oSize.Width*Ratio)
				oShape.setSize(oSize)
			end if			
		Next j		 
   	Next i
   	
End Sub

The macro will change the size of all MAGES on the pages to 6 cm width and it try to preserve the original ratio (the ratio what the images have before the macro running) .

Of course you can calculate and set the Position of the images in same way.

1 Like
REM  *****  BASIC  *****
Option explicit 


Sub ResizeImages

 Dim oDrawDoc as object
 Dim oPages, oDrawPage as object
 Dim oShape as object
 Dim oSize as object
 Dim Ratio as double
 Dim iPageCount, iShapeCount, i, j as integer
 
 	oDrawDoc = Thiscomponent()
	oPages = oDrawDoc.GetDrawPages()
	iPageCount = oPages.GetCount() 
	For i = 0 to iPageCount-1
		oDrawPage = oDrawDoc.DrawPages(i)
		For j = 0 To oDrawPage.getCount()-1 
			oShape = oDrawPage.getByIndex(j)
			if oShape.supportsService("com.sun.star.drawing.GraphicObjectShape") then
				oSize = oShape.getSize()	
				Ratio = oSize.Height/oSize.Width
				oSize.Width = 6000 'in unit hundredths of a millimeter
				oSize.Height = 4000 'in unit hundredths of a millimeter
				oShape.setSize(oSize)
			end if			
		Next j		 
   	Next i
   	
End Sub

I’m more interested the images to have my size so i used that instead, thank you!

1 Like