View Full Version : rename and resize .jpg?
ianhull
08-20-2005, 12:59 PM
Hi guys,
is it possible to resize a jpg to say. 200 x 200?
if you know how I would appreciate it if you could help.
Thanks
Bruce
08-20-2005, 01:03 PM
What size is the jpg now and when do you want to resize the pic?
ianhull
08-20-2005, 01:05 PM
Sorry Bruce I should of given more detail.
I would like a user to select a .jpg from there machine and have autoplay rename and resize it so that my Flash application can read the file and have it at the right size.
Thanks
longedge
08-20-2005, 01:50 PM
Worm's post here (http://www.indigorose.com/forums/showpost.php?p=47061&postcount=17) is what you want I think :) :yes
ianhull
08-20-2005, 02:28 PM
Thanks Longedge,
I really need to save the image afterwards aswell.
Any ideas on how this can be achieved?
if not I think that flash has a scale movie clip function I will have to look into doing it that way.
longedge
08-20-2005, 03:10 PM
Hi Ian,
I've never used the method myself, but I know that IRFANVIEW (http://www.irfanview.com/) can do the resizing from a command line which might fit the bill for you, after which you could then save the file out to a hd folder.
Corey
08-20-2005, 03:31 PM
Irfanview is ideal for this, it has all sorts of command line switches, but if you are using it for commercial use there's a license one has to purchase. Probably cheap though... :yes
Intrigued
08-20-2005, 10:04 PM
Don't forget this gem:
http://www.imagemagick.org/script/index.php
Command-line:
http://www.imagemagick.org/script/command-line-tools.php
I recommended I.R. take a look before (and now again) at using the available source code in their AMS offerings.
:yes
Intrigued
08-21-2005, 12:50 AM
Here is an example on how to use the .exe in the forementioned package I supplied to resize an image. Oh! there is lots you can do with that package! It seems to totally rock once you get the hang of it. :yes (puts pom poms away)
Okay, here is the deal...
I went ahead and downloaded and installed to a blank folder and then copied that over into a new AMS 6 beta 4 Project (folder area).
Next I took a screenshot (just choose or create a .jpg image that's larger than 256x256) and added that into the project (what is this... a stew I'm working on you ask? ;))
Then, via the documentation supplied with the package, used the .exe via command-line to get the resize-of-the-.jpg-image deal to work. I would have printed out a copy of the code.. but the CodeViewer Brett so graciously put out for us for AMS 5 does not have a filter setup for AMS 6 (so it sees those file extentions).
Anyway, take this for a spin and see what you come up with. I recommend that you do like I did and moved all of the install files from the package (ImageMagic) into a folder and bump that into a project and save that as your template for future needs.
:yes
AMS 6 beta (4) .apz file:
http://www.amsuser.com/ams/examples/ImageMagic(Resize)-others-Intrigued.apz
Intrigued
08-21-2005, 12:56 AM
Here is an .exe AMS 6 beta (4) example:
Note: Remember that AMS 6 beta .exes last only for four (4) days! So, check this out sooner than later, if you are curious.
http://www.amsuser.com/ams/examples/ImageMagic(Resize)-others-Intrigued.exe
TJ_Tigger
08-21-2005, 10:49 AM
I ran across this lua library for image manipulation on SourceForge. I have not played with it but I would think that it might be possible to use its functions within AMS. Worth a try.
http://luaforge.net/projects/lua-gd/
Tigg
ianhull
08-21-2005, 02:00 PM
Thanks for all the help and advice you guys, much appreciated.
I will have to learn about using the command line because right now that is foreign to me lol. have not got a clue where to start or anything but I will see if I can learn it.
ianhull
08-21-2005, 02:09 PM
I have downloaded the source forge file and it has a few samples in there but to be honest I have not got a clue how to get them to work with autoplay
I opened the .lua file into autoplay and it gave me this code.
Does it make sense to any of you?
-- Thumbnail generator, powered by lua and lua-gd
-- (c) 2004 Alexandre Erwin Ittner <aittner AT netuno DOT com DOT br>
-- Distributed under the terms of GNU GPL, version 2 or (at your option)
-- any later version. THERE IS NO WARRANTY OF ANY KIND!!
-- This program runs under Unix only and requires the Luiz Henrique de
-- Figueiredo's POSIX extension for Lua, which can be donwloaded from
-- http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/
-- $Id: mkthumbs.lua,v 1.15 2005/03/06 01:32:35 dermeister Exp $
require "gd"
thumbsize = 120 -- thumbnail size
tablecols = 5 -- columns on table
header = [[
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Thumbnails for {DIRNAME}</title>
<meta **********="Content-Type" content="text/html; charset=ISO-8859-1">
<style type="text/css">
<!--
H1 {
font-family: Verdana, Arial, helvetica, sans-serif;
font-size: 18px;
color: black;
background-color: white;
text-align: center;
}
BODY {
font-family: Verdana, Arial, helvetica, sans-serif;
font-size: 11px;
color: black;
background : white;
}
TABLE {
border: 0px;
}
TR, TD {
font-family: Verdana, Arial, helvetica, sans-serif;
font-size: 11px;
border: 0px;
background-color: white;
padding: 0px;
cell-spacing: 1px;
}
.small {
font-size: 9px;
}
-->
</style>
</head>
<body>
<h1>Thumbnails for {DIRNAME}</h1>
<center>
<table>
]]
footer = [[
</table>
</center>
<hr>
<div class="small">Generated by mkthumbs.lua powered by
<a href="http://lua-gd.luaforge.net/projects/">Lua-GD</a>.</div>
</body>
</html>
]]
if arg[1] == nil then
print("usage: mkthumbs.lua <directory>")
os.exit(1)
end
load_posix = loadlib("lposix.so", "luaopen_posix")
if load_posix == nil then
print("Error: Can't find the POSIX library. Do you have it, you don't?")
os.exit(1)
end
load_posix()
function makeThumb(dirname, fname)
local im
local tmpname = string.lower(fname)
local s, e, name, tname
local thumbname, fulltname
local format
local fullname = dirname .. "/" .. fname
s, e, name = string.find(tmpname, "thumb_(.+)%.png")
if name then
return nil
end
s, e, name = string.find(tmpname, "(.+)%.png")
if name then
im = gd.createFromPng(fullname)
format = "PNG"
tname = name
end
s, e, name = string.find(tmpname, "(.+)%.jpe?g")
if name then
im = gd.createFromJpeg(fullname)
format = "JPEG"
tname = name
end
s, e, name = string.find(tmpname, "(.+)%.gif")
if name then
im = gd.createFromGif(fullname)
format = "GIF"
tname = name
end
if im == nil then
return nil
end
thumbname = "thumb_" .. tname .. ".png"
fulltname = dirname .. "/" .. thumbname
local sx, sy = im:sizeXY()
local tsy, tsy, rtsy
if sx <= thumbsize and sy <= thumbsize then
tsx, tsy = sx, sy
else
local factor
factor = math.max(1, sx/thumbsize, sy/thumbsize)
tsx, tsy = math.floor(sx/factor), math.floor(sy/factor)
end
rtsy = tsy + 15
tim = gd.createTrueColor(tsx, rtsy)
tim:copyResampled(im, 0, 0, 0, 0, tsx, tsy, sx, sy)
local black = tim:colorExact(0, 0, 0)
local white = tim:colorExact(255, 255, 255)
local info = format .. ", " .. sx .. "x" .. sy .. "px"
tim:filledRectangle(0, tsy, tsx, rtsy, black)
tim:string(gd.FONT_SMALL, 2, tsy+1, info, white)
if tim:png(fulltname) then
return thumbname, tsx, rtsy, fname
end
return nil
end
dirname = arg[1]
indexname = dirname .. "/index.html"
filelist = posix.dir(dirname)
if filelist == nil then
print("Error: Can't access directory '" .. dirname .. "'")
os.exit(1)
end
fp = io.open(indexname, "w")
if fp == nil then
print("Error: Can't open '" .. indexname .. "' for writting.")
os.exit(1)
end
nheader = string.gsub(header, "{DIRNAME}", dirname)
fp:write(nheader)
fp:write(" <tr>\n")
cols = 0
numtbs = 0
for i, name in ipairs(filelist) do
tname, sx, sy, fname = makeThumb(dirname, name)
if tname then
print("Processing " .. fname .. " ...")
fp:write(" <td> <a href=\"" .. fname .. "\"> <img src=\""
.. tname .."\" width=\"" .. sx .. "\" height=\"" .. sy
.."\" border=\"no\"> </a> </td>\n")
cols = cols + 1
if cols > tablecols then
fp:write(" </tr>\n <tr>\n")
cols = 0
end
numtbs = numtbs + 1
end
end
fp:write(" </tr>\n")
fp:write(footer)
fp:close()
print("DONE: " .. indexname .. " generated with " .. numtbs .. " thumbnails")
Intrigued
08-21-2005, 08:35 PM
Well, what I put forth is about as simple as you can get. It's command-line.
:yes
Give it a shot.. check out the .apz.
Dermot
08-22-2005, 12:25 AM
-- This program runs under Unix only and requires the Luiz Henrique de
-- Figueiredo's POSIX extension for Lua, which can be donwloaded from
-- http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/
I would say this bit right here tells you it aint going to work.
load_posix = loadlib("lposix.so", "luaopen_posix")
And this.
TJ_Tigger
08-22-2005, 12:37 AM
I would say this bit right here tells you it aint going to work.
And this.
Hmmm. That will teach me that I need to read the site a little better before I go posting. I ran across it when I was searching for some Lua stuff online and bookmarked it as a potential page to revisit.
Well it was worth a shot.
Tigg
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.