forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


maintain aspect ratio

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Rubes_sw
Valued Contributor
Valued Contributor


Joined: 11 Jun 2001
Posts: 625
Location: Northern Ireland

PostPosted: Thu Oct 07, 2004 8:19 am    Post subject: maintain aspect ratio Reply with quote

Anyone any code lying around for maintain aspect ratio

I want to use vdsconv.dll to convert images to a set size, but i want to keep the aspect ratio, I know it would invlove a bit of maths etc.

Any ideas?

Nathan
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bbelcher
Contributor
Contributor


Joined: 30 Jul 2002
Posts: 172

PostPosted: Thu Oct 07, 2004 1:28 pm    Post subject: Reply with quote

I use this code to resize images to specific parameters before I print them. I hope this helps and is not to confusing.

Code:

   if @null(%%printpix)
         info Nothing to PRINT. Please load a graphic first.
         goto loop
      else
      end
      rem      %%picg = %%curdirtemp\%%pic
      %%imgheight = @CONVERT(IMGHEIGHT,%%printpix)
      %%imgwidth = @CONVERT(IMGWIDTH,%%printpix)
      %%aspectratio = @FDIV(%%imgwidth,%%imgheight)


rem if image height is greater the width i.e. portrait. Also image is sized to fit into a 950 pix tall area.
      if @greater(%%imgheight,%%imgwidth)
         if @greater(%%imgheight,951)
            rem         info %%aspectratio %%imgwidth %%imgheight
            %%downscalewidth = @FMUL(950,%%aspectratio)
            %%printwidth = %%downscalewidth
            %%printheight = 950
         else
            %%upscalewidth = @FMUL(950,%%aspectratio)
            %%printwidth = %%upscalewidth
            %%printheight = 950
         end
      end

rem if image width is greter then height i.e. landscape Also image is sized to fit into a 765 pix width area.
      if @greater(%%imgwidth,%%imgheight)
         if @greater(%%imgwidth,766)
            rem         info %%aspectratio %%imgwidth %%imgheight
            %%downscaleheight = @FDIV(765,%%aspectratio)
            %%printwidth = 765
            %%printheight = %%downscaleheight
         else
            %%upscalehight = @FDIV(765,%%aspectratio)
            %%printwidth = 765
            %%printheight = %%upscalehight
         end
      end

rem if image is square fits square 765 pix area.
      if @equal(%%imgheight,%%imgwidth)
         %%printwidth = 765
         %%printheight = 765
      end
Back to top
View user's profile Send private message
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Sat Oct 09, 2004 3:36 pm    Post subject: Reply with quote

Not sure, but you may find these postings useful, too:

http://forum.vdsworld.com/viewtopic.php?p=16375&highlight=#16375

http://www.vdsworld.com/forum/viewtopic.php?t=2172

Cheers,

- Boo
Back to top
View user's profile Send private message
Vic D'Elfant
Past Contributor
Past Contributor


Joined: 26 Jun 2002
Posts: 673
Location: The Netherlands

PostPosted: Sat Oct 23, 2004 6:07 pm    Post subject: Reply with quote

I wrote a similar program a few months ago... Perhaps this code is usefull to you... Smile

Code:

list create, 1
list add, 1, C:\blah\blub.jpg
# etc... all items should be full paths to the file

# Maximum height
%%Height = 100
# Maximum width
%%Width = 100
# Output directory
%%OutputFolder = @path(%0)scaled

if @greater(@convert(imgheight, @item(1)), %%Height) @greater(@convert(imgwidth, @item(1)), %%Width)
   if @greater(@convert(imgheight, @item(1)), @convert(imgwidth, @item(1)))
      %%Factor = @fdiv(@convert(imgwidth, @item(1)), @convert(imgheight, @item(1)))
      convert scale, @item(1), %%OutputFolder\@name(@item(1)).@ext(@item(1)), @format(@fmul(%%Height, %%Factor), .0), %%Height
   else
      %%Factor = @fdiv(@convert(imgheight, @item(1)), @convert(imgwidth, @item(1)))
      convert scale, @item(1), %%OutputFolder\@name(@item(1)).@ext(@item(1)), %%Width, @format(@fmul(%%Width, %%Factor), .0)
   end
end


Vic

_________________
phpBB Development Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group