Thủ thuật resize ảnh hàng loạt trên Windows 10

vn_ninja
2/9/2019 3:9Phản hồi: 65
Thủ thuật resize ảnh hàng loạt trên Windows 10
Để resize (thay đổi kích thước) ảnh trên Windows 10 ta có thể dùng chức năng Edit của ứng dụng Photos mặc định để resize ảnh, nhưng để resize nhiều ảnh trên Windows 10 mà không cần đến ứng dụng bên thứ ba thì làm thế nào? Mình xin chia sẻ một thủ thuật nhỏ

Đầu tiên gom hết các ảnh cần resize vào một folder, xong tạo một folder mới để chứa ảnh đã resize, ở đây mình gom 5 ảnh vào folder Raw, trong folder Raw, bấm Ctrl + A để chọn tất cả ảnh, sau đó nhấp chuột phải chọn Send to, Mail recipient


1.jpg

Lúc này hiện ra một cửa sổ Attach Files, trong mục Picture size lúc này ta có thể chọn kích thước cho ảnh với các size cố định là Smaller 640 480, Small 800 600, Medium 1024 768, Large 1280 1024, và Original Size là kích thước gốc

7.jpg


Sau khi chọn xong sẽ hiện tổng dung lượng file ảnh đã resize ở dưới, mình chọn kích thước 1024 768 thì tổng dung lượng là 1.12 MB, xong nhấn Attach

2.jpg

Lúc này Outlook sẽ hiện lên, trong phần Attached sẽ có các ảnh đính kèm, đây là các ảnh đã được resize thành công.

3.jpg

Để lưu ảnh lại ta nhấp vào phần mũi tên của một ảnh, chọn Select all


4.jpg

Xong nhấn chuột phải vào một ảnh chọn Save as, chọn folder lưu là xong

5.jpg

Quảng cáo



Lúc này trong folder Resized đã có các ảnh được resize

6.jpg

Ưu điểm của phương pháp này là không cần cài thêm phần mềm bên thứ ba, mặc định Windows 10 có outlook là dùng được.

Nhược điểm là ta chỉ có thể resize hàng loạt theo từng kích thước cố định, không tùy chỉnh kích thước được


Thủ thuật nhỏ trong Windows 10, anh em thấy thế nào? Chia sẻ ý kiến nhé😁
65 bình luận
Chia sẻ

Xu hướng

Windows 10 giờ đã tốt rất nhiều...iêu nhiêu nhiều
Hay
@vn_ninja
Quá khổ sở chứ hay gì ! Thứ nữa là nó chỉ resize theo một vài kích thước cố định.
Cách đơn giản, mở notepad, paste đoạn code sau vào, và lưu thành run.bat và kết hợp với scale.bat. Sau đó chạy lên bằng cmd. Lưu ý là đổi tên thư mục và kích thước ảnh (bôi đỏ).

run.bat
@echo off
set "source_folder=
c:\images"
set "result_folder_1=
c:\res1"
set "result_folder_2=
c:\res2"

for %%a in ("%source_folder%\*
jpg") do (
call scale.bat -source "%%~fa" -target "%result_folder_1%\%%~nxa" -max-height
250 -max-width 250 -keep-ratio no -force yes
)

for %%a in ("%source_folder%\*
jpg") do (
call scale.bat -source "%%~fa" -target "%result_folder_2%\%%~nxa" -max-height
125 -max-width 125 -keep-ratio no -force yes
)

scale.bat
@if (@X)==(@Y) @end /* JScript comment
@echo off
cscript //E:JScript //nologo "%~f0" %*
::pause
exit /b %errorlevel%
@if (@X)==(@Y) @end JScript comment */
//https://msdn.microsoft.com/en-us/library/windows/desktop/ms630819(v=vs.85).aspx
var imageFile = new ActiveXObject("WIA.ImageFile");
var imageProcess = new ActiveXObject("WIA.ImageProcess");
var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
var ARGS=WScript.Arguments;
/******
Scale filter description:
Scales image to the specified Maximum Width and Maximum Height preserving
Aspect Ratio if necessary.
MaximumWidth - Set the MaximumWidth property to the width (in pixels)
that you wish to scale the image to.
MaximumHeight - Set the MaximumHeight property to the height (in pixels)
that you wish to scale the image to.
PreserveAspectRatio - Set the PreserveAspectRatio property to True
[the default] if you wish to maintain the current aspect
ration of the image, otherwise False and the image will
be stretched to the MaximumWidth and MaximumHeight
FrameIndex - Set the FrameIndex property to the index of a frame if
you wish to modify a frame other than the ActiveFrame,
otherwise 0 [the default]

******/
//defaults
var maxWidth=0;
var maxHeight=0;
var pRatio=true;
var frameIndex=0;
var source="";
var target="";
var force=false;
var height=0;
var width=0;
var percentage=false;
////////////////////////////
//// //
/**/ var QUALITY=100; //
//// //
////////////////////////////
function existsFile(path){
if (fileSystem.FileExists(path))
return true;
}
function existsFolder(path){
if (fileSystem.FolderExists(path))
return true;
}
function deleteFile(path){
fileSystem.DeleteFile(path);
}
function loadImage(image,imageFile){
try{
image.LoadFile(imageFile);
}catch(err){
WScript.Echo("Probably "+imageFile+" is not a valid image file");
WScript.Echo(err.message);
WScript.Quit(30);
}
height=image.Height;
width=image.Width;
}
function ID2Format(id){
var ids={};
ids["{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"]="BPM";
ids["{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"]="PNG";
ids["{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}"]="GIF";
ids["{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"]="JPG";
ids["{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"]="TIFF";

return ids[id];
}
function format2ID(format){
formats={};
formats["BMP"]="{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}";
formats["PNG"]="{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}";
formats["GIF"]="{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}";
formats["JPG"]="{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}";
formats["TIFF"]="{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}";

return formats[format];
}
function convert(image,format){
var ic=imageProcess.Filters.Count;
var filterFormat=format2ID(format);
if(filterFormat==null){
WScript.Echo("not supported target format "+format);
WScript.Quit(90);
}
imageProcess.Filters.Add(imageProcess.FilterInfos("Convert").FilterID);
imageProcess.Filters(ic+1).Properties("FormatID").Value = filterFormat;
imageProcess.Filters(ic+1).Properties("Quality").Value = QUALITY;
}
function scale(){
if(maxHeight<=0){
WScript.Echo("MaximumHeight ("+maxHeight+") should be bigger than 0");
WScript.Quit(80);
}

if(maxWidth<=0){
WScript.Echo("MaximumHeight ("+maxWidth+") should be bigger than 0");
WScript.Quit(81);
}

var ic=imageProcess.Filters.Count;
//var filterFormat=format2ID(format);
imageProcess.Filters.Add(imageProcess.FilterInfos("Scale").FilterID);

imageProcess.Filters(ic+1).Properties("MaximumWidth").Value = maxWidth;
imageProcess.Filters(ic+1).Properties("MaximumHeight").Value = maxHeight;
//WScript.Echo(pRatio+"::"+maxWidth+"::"+maxHeight+">>"+width+"++"+height);
imageProcess.Filters(ic+1).Properties("PreserveAspectRatio").Value = pRatio;
imageProcess.Filters(ic+1).Properties("FrameIndex").Value = frameIndex;
}
function fromPerc(){
maxWidth=Math.round((width*maxWidth)/100);
maxHeight=Math.round((height*maxHeight)/100);
if(maxHeight==0)
maxHeight=1;
if(maxWidth==0)
maxWidth=1;
}
function printHelp(){
WScript.Echo( WScript.ScriptName + " - resizes an image");
WScript.Echo(" ");
WScript.Echo(WScript.ScriptName + "-source source.file -target file.format [-max-height height] [-max-width width] [-percentage yes|no] [-keep-ratio yes|no] [-frame-index -0.5..1] ");
WScript.Echo("-source - the image that will flipped or rotated.");
WScript.Echo("-target - the file where the transformations will be saved in.If the file extension format is different than the source it will be converted to the pointed one.Supported formats are BMp,JPG,GIF,TIFF,PNG");
WScript.Echo("-percentage - whether the rescale will be calculated in pixels or in percentages.If yes percentages will be used.Default is no.");
WScript.Echo("-force - If yes and the target file already exists , it will be overwritten");
WScript.Echo("-max-height - max height of the image");
WScript.Echo("-max-width - max width of the image");
WScript.Echo("-keep-ratio - if dimensions ratio will be preserved.Default is yes");
WScript.Echo("-frame-index - Have no idea what this is used for , but it is pressented in the rotation filter capabilities.Images with this and without looks the same.Accepted values are from -0.5 to 1");

}
function parseArguments(){
if (WScript.Arguments.Length<4 || ARGS.Item(1).toLowerCase() == "-help" || ARGS.Item(1).toLowerCase() == "-h" ) {
printHelp();
WScript.Quit(0);
}

if (WScript.Arguments.Length % 2 == 1 ) {
WScript.Echo("Illegal arguments ");
printHelp();
WScript.Quit(1);
}

//ARGS
for(var arg = 0 ; arg<ARGS.Length-1;arg=arg+2) {
if (ARGS.Item(arg) == "-source") {
source = ARGS.Item(arg +1);
}
if (ARGS.Item(arg) == "-target") {
target = ARGS.Item(arg +1);
}
if (ARGS.Item(arg).toLowerCase() == "-force" && (ARGS.Item(arg +1).toLowerCase() == "yes" || ARGS.Item(arg +1).toLowerCase() == "true") ) {
force=true;
}

if (ARGS.Item(arg).toLowerCase() == "-percentage" && (ARGS.Item(arg +1).toLowerCase() == "yes" || ARGS.Item(arg +1).toLowerCase() == "true") ) {
percentage=true;
}

if (ARGS.Item(arg).toLowerCase() == "-keep-ratio" && (ARGS.Item(arg +1).toLowerCase() == "no" || ARGS.Item(arg +1).toLowerCase() == "false") ) {
pRatio=false;
}

if (ARGS.Item(arg).toLowerCase() == "-max-width") {
try {
maxWidth=parseInt(ARGS.Item(arg +1));
} catch (err){
WScript.Echo("Wrong argument:");
WScript.Echo(err.message);
WScript.Quit(10);
}

}

if (ARGS.Item(arg).toLowerCase() == "-max-height") {
try {
maxHeight=parseInt(ARGS.Item(arg +1));
} catch (err){
WScript.Echo("Wrong argument:");
WScript.Echo(err.message);
WScript.Quit(15);
}

}


if (ARGS.Item(arg).toLowerCase() == "-frame-index") {
try {
frameIndex=parseFloat(ARGS.Item(arg +1));
if(frameIndex<-0.5 || frameIndex > 1){
WScript.Echo("Wrong argument - frame index should be between -0.5 and 1");
WScript.Quit(25);
}

} catch (err){
WScript.Echo("Wrong argument:");
WScript.Echo(err.message);
WScript.Quit(20);
}
}
}

if (target==""){
WScript.Echo("Target file not passed");
WScript.Quit(5);
}

if(source==""){
WScript.Echo("Source file not passed");
WScript.Quit(6);
}
}
parseArguments();
if(!existsFile(source)){
WScript.Echo("Source image: " + source +" does not exists");
WScript.Quit(40);
}
if(existsFile(target) && !force){
WScript.Echo("Target image: " + target +" already exists");
WScript.Quit(45);
}
if(existsFolder(target)){
WScript.Echo("There's existing folder with the target file (" + target +") name");
WScript.Quit(46);
}
if(existsFile(target) && force){
deleteFile(target);
}
var targetFormat=target.split(".")[target.split(".").length-1].toUpperCase();
loadImage(imageFile,source);
var sourceFormat=ID2Format(imageFile.FormatID);
if(maxWidth==0 && !percentage){
maxWidth=width;
}
if(maxHeight==0 && !percentage){
maxHeight=height;
}
if(maxWidth==0 && percentage){
maxWidth=100;
}
if(maxHeight==0 && percentage){
maxHeight=100;
}
if(percentage){
fromPerc();
}
///
scale();
///
if (sourceFormat !== targetFormat ){
convert(resImg,targetFormat);
}
var resImg=imageProcess.Apply(imageFile);
resImg.SaveFile(target);

@micheal9000 Để thử xem sao?
mrso
ĐẠI BÀNG
5 năm
@micheal9000 Hoa cả mắt, cài app thứ 3 cho nó lành thôi bác o_O
GragonV
CAO CẤP
5 năm
@micheal9000 thấy khổ sở ko kém =)))
@mrso Copy paste thôi mà. Notepad và CMD thì window nào chả có 😃 Đây là resize hàng loạt 😃
hữu ích giờ mới biết. Cảm ơn bạn.
khoanhotn
TÍCH CỰC
5 năm
Tks bác, đang cần này 😁
Outlook là phần mềm thứ 3 rồi còn gì. Mặc định làm gì có outlook...
@binhtran89 Tui thấy mặc định ai dùng window cũng cài bộ office mà
thanhtung08
ĐẠI BÀNG
5 năm
@khanhduy.39n @khanhduy.39n, @binhtran89 nói đúng mà. Bắt bẻ cái gì. Tui xài ở nhà đâu có cài office vào đâu. Muốn xài ofice thì có bộ google doc hay microsoft office online đó.
ltb1974
ĐẠI BÀNG
5 năm
@binhtran89 Windows 10 có Outlook (Mail) đi kèm, không phải MS Office Outlook nhé bạn.
aloso88
TÍCH CỰC
5 năm
Cũng hay đấy, nhưng máy cài photoshop rồi
hungbui90
ĐẠI BÀNG
5 năm
Khá hay
Hay nhưng nhớ ghi nguồn thím ơi
Nhiều khi bí quá thì đây là một cách hay. Thanks
wjzhweo
ĐẠI BÀNG
5 năm
Vừa test cho windows 8.1 và Outlook 2010 vẫn làm được anh em nhé. 😃
tearofthesun
ĐẠI BÀNG
5 năm
@wjzhweo Ok bạn :-bd
Rất hay ạ, tks ad nhiều
tanifood
ĐẠI BÀNG
5 năm
Hay quá, cám ơn bạn
xikiuwant
TÍCH CỰC
5 năm
@hoangduytung Thằng mod xl. Rảnh ko có việc gì làm nên đi cóp nhặt linh tinh cho đủ bài.
@hoangduytung Hehe vừa post bài bên dưới thì đọc được bài này 😆
mình thì chọn upload_2019-9-2_21-54-52.png
linhnikon
ĐẠI BÀNG
5 năm
Tiếc là không có 2048, anh em cúng ảnh Facebook thường dùng size này.
tranqcuong
TÍCH CỰC
5 năm
Winxp cũng làm được, cần gì phải win10
oxechip
TÍCH CỰC
5 năm
Cách này hay quá, vậy mà trước giờ e toàn up lên google photo xong rồi tải xuống. Hình tự giảm dung lượng lun
rất hay, tks bác

Xu hướng

Bài mới









  • Chịu trách nhiệm nội dung: Trần Mạnh Hiệp
  • © 2024 Công ty Cổ phần MXH Tinh Tế
  • Địa chỉ: Số 70 Bà Huyện Thanh Quan, P. Võ Thị Sáu, Quận 3, TPHCM
  • Số điện thoại: 02822460095
  • MST: 0313255119
  • Giấy phép thiết lập MXH số 11/GP-BTTTT, Ký ngày: 08/01/2019