Page 1 of 1
[solved] Need help with copy pixels - resize and paste into another region
Posted: 2016-07-08T02:02:20-07:00
by Avanatus
Hello all,
I searched but did not find the solution - maybe someone can help me.
Original: Format *.dds - size 128x128 - position region: 25,36 - size region: 71x48
i want to convert to:
Converted: Format *.dds - size 64x64 - position region: 12,16 - size region: 34x24
I try the convert Option.
Resize to 64x64 works - code for my batchfile:
for %%f in (*.dds) do ( convert %%f -resize 64x64 -define dds:mipmaps=2 -define dds:compression=none "converted\%%f" )
In the moment i would like to do:
1. copy region from original to new image (tempimage1)
2. resize(tempimage1) to new size (tempimage2)
2. create transparent canvas from original (tempimage3)
3. resize transparent canvas(tempimage2) to new size (tempimage4)
4. copy (tempimage2) to new region (tempimage4) (outputimage1)
Is there a way with options to do it in one go? - so without the tempimage's?
would be nice if someone can help me on that topic
Thanks for help
Avanatus
Re: Need help with copy pixels - resize and paste into another region
Posted: 2016-07-08T03:13:07-07:00
by snibgo
I don't understand what you want. Perhaps you want to:
(1) From an input image that is 128x128, make an output that is 64x64. You have done that.
(2) From the same input image, crop out an area 71x48+25+36, resize that to 34x24, and paste that over the output at offset 12,16.
Is that what you want?
(2) could be:
Code: Select all
convert output.dds ( input.dds -crop 71x48+25+36 +repage ) -geometry 12,16 -compose Over -composite output.dds
Adjust syntax as needed for your shell.
Re: Need help with copy pixels - resize and paste into another region
Posted: 2016-07-08T05:20:41-07:00
by Avanatus
Hello snibgo,
yes thats what i want to do
All seems clear to me except where you resize the image to 34x24....?
Re: Need help with copy pixels - resize and paste into another region
Posted: 2016-07-08T05:54:08-07:00
by snibgo
Sorry, yes, I forgot the resize.
Code: Select all
convert output.dds ( input.dds -crop 71x48+25+36 +repage -resize 34x24 ) -geometry 12,16 -compose Over -composite output.dds
If the two converts do what you want, you can then combine them into a single convert.
Re: Need help with copy pixels - resize and paste into another region
Posted: 2016-07-08T09:46:55-07:00
by Avanatus
Hi snibgo,
i am working on a windows desktop with win7
At first i had problems with directorys with spaces in it, so i changed to directorys without spaces in the names.
Now all worked until your code^^.
Here is the batchfile i am using:
Code: Select all
del tempimage1\*.dds
del tempimage2\*.dds
del tempimage3\*.dds
del outputimage1\*.dds
:: Batchfile for ImageMagick - by ava 06072016
:: Converting DDS files from 128x128 into 64x64 DDS Files and replacing the position
::Turn of displaying the code on the screen
@echo on
:: Read all the dds images from the directory, resize them, and save as a dds in a different directory
setLocal ENABLEDELAYEDEXPANSION
SET IMCONV="%PROGRAMFILES%\ImageMagick"
CD %~p1
for %%f in (*.dds) do (
set filename=%%~nf
set filepath=%%~pf
convert "%%f" -crop 71x48+25+36 -define dds:compression=none "!filepath!tempimage1\!filename!.dds"
)
cd tempimage1
for %%f in (*.dds) do (
set filename=%%~nf
convert "%%f" -resize 34x24 -define dds:compression=none "!filepath!tempimage2\!filename!.dds"
)
cd..
for %%f in (*.dds) do (
set filename=%%~nf
convert "%%f" -alpha transparent -resize 64x64 -define dds:compression=none "!filepath!tempimage3\!filename!.dds"
)
cd tempimage3
for %%f in (*.dds) do (
set filename=%%~nf
convert "%%f" ( "!filepath!\!filename!.dds" -crop 71x48+25+36 +repage -resize 34x24 ) -geometry 12,16 -compose Over -composite "!filepath!outputimage1\!filename!.dds"
)
:: -define dds:compression={dxt1, dxt5, none}
endlocal
pause
The batchfile works until the convert inside the convert....
Maybe a syntax error?
Thanks for help
Avanatus
Re: Need help with copy pixels - resize and paste into another region
Posted: 2016-07-08T10:18:21-07:00
by snibgo
When your command contains parentheses ( and )
within a "for" if "if" parentheses, you need to escape them.
Code: Select all
convert "%%f" ^( "!filepath!\!filename!.dds" -crop 71x48+25+36 +repage -resize 34x24 ^) -geometry 12,16 -compose Over -composite "!filepath!outputimage1\!filename!.dds"
Re: Need help with copy pixels - resize and paste into another region
Posted: 2016-07-08T11:09:57-07:00
by Avanatus
Thanks snibgo - it helps....
Now i get an error from the convert module "convert: invalid geometry `12,16' @ error/geometry.c/ParseRegionGeometry/1542."
Hmpf^^
Re: Need help with copy pixels - resize and paste into another region
Posted: 2016-07-08T11:19:38-07:00
by snibgo
See the manual at
http://www.imagemagick.org/script/comma ... p#geometry and follow the link. It gives you the required syntax.
Re: Need help with copy pixels - resize and paste into another region
Posted: 2016-07-08T11:47:49-07:00
by Avanatus
Ahh... thanks
Forgot the + sighns^^
now:
Code: Select all
convert "%%f" ^( "!filepath!\!filename!.dds" -crop 71x48+25+36 +repage -resize 34x24 ^) -geometry +12+16 -compose Over -composite "!filepath!outputimage1\!filename!.dds"
)
...works like a charm^^
Thanks a million for help
Avanatus
Re: Need help with copy pixels - resize and paste into another region
Posted: 2016-07-08T11:48:45-07:00
by Avanatus
How can i set the thread to "solved"?
Re: Need help with copy pixels - resize and paste into another region
Posted: 2016-07-08T11:54:24-07:00
by fmw42
Avanatus wrote:How can i set the thread to "solved"?
Edit the title of your very first (top) post in this thread.
Re: [solved] Need help with copy pixels - resize and paste into another region
Posted: 2016-07-08T12:23:07-07:00
by Avanatus
Done - and thanks for help