質問編集履歴

4

正常に動作確認済み

2018/03/27 03:18

投稿

ZZ-TOP
ZZ-TOP

スコア36

test CHANGED
File without changes
test CHANGED
@@ -201,3 +201,49 @@
201
201
  )
202
202
 
203
203
  ```
204
+
205
+
206
+
207
+ ```バッチファイル
208
+
209
+ setlocal enabledelayedexpansion
210
+
211
+ REM ↑このコマンドは必要!
212
+
213
+
214
+
215
+ for %%f in (*.png) do (
216
+
217
+ REM 画像の縦幅を取得
218
+
219
+ REM "%%h"でくくる、「'」でくくると文字扱いになる=条件式が機能しない
220
+
221
+ for /f "usebackq tokens=*" %%i in (`identify -format "%%h" %%f`) do @set HEIGHT=%%i
222
+
223
+
224
+
225
+ REM 画像の横幅を取得
226
+
227
+ for /f "usebackq tokens=*" %%i in (`identify -format "%%w" %%f`) do @set WIDTH=%%i
228
+
229
+
230
+
231
+
232
+
233
+ if !HEIGHT! GEQ !WIDTH! (
234
+
235
+ REM 縦幅 >= 横幅
236
+
237
+ convert -resize x900 %%f %%~nf_resized.png
238
+
239
+ ) else (
240
+
241
+ REM 縦幅 < 横幅
242
+
243
+ convert -resize 900x %%f %%~nf_resized.png
244
+
245
+ )
246
+
247
+ )
248
+
249
+ ```

3

2回目のアドバイス

2018/03/27 03:18

投稿

ZZ-TOP
ZZ-TOP

スコア36

test CHANGED
File without changes
test CHANGED
@@ -163,3 +163,41 @@
163
163
  )
164
164
 
165
165
  ```
166
+
167
+
168
+
169
+ ```バッチファイル
170
+
171
+ for %%f in (*.png) do (
172
+
173
+ REM 画像の縦幅を取得
174
+
175
+ for /f "usebackq tokens=*" %%i in (`identify -format "%%h" %%f`) do @set HEIGHT=%%i
176
+
177
+
178
+
179
+ REM 画像の横幅を取得
180
+
181
+ for /f "usebackq tokens=*" %%i in (`identify -format "%%w" %%f`) do @set WIDTH=%%i
182
+
183
+
184
+
185
+
186
+
187
+ if !HEIGHT! GEQ !WIDTH! (
188
+
189
+ REM 縦幅 >= 横幅
190
+
191
+ convert -resize x900 %%f %%~nf_resized.png
192
+
193
+ ) else (
194
+
195
+ REM 縦幅 < 横幅
196
+
197
+ convert -resize 900x %%f %%~nf_resized.png
198
+
199
+ )
200
+
201
+ )
202
+
203
+ ```

2

アドバイスにより追加

2018/03/27 02:18

投稿

ZZ-TOP
ZZ-TOP

スコア36

test CHANGED
File without changes
test CHANGED
@@ -119,3 +119,47 @@
119
119
  )
120
120
 
121
121
  ```
122
+
123
+
124
+
125
+ ```バッチファイル
126
+
127
+ for %%f in (*.png) do (
128
+
129
+ REM 画像の縦幅を取得
130
+
131
+ for /f "usebackq tokens=*" %%i in (`identify -format '%%h' %%f`) do @set HEIGHT=%%i
132
+
133
+
134
+
135
+ REM 画像の横幅を取得
136
+
137
+ for /f "usebackq tokens=*" %%i in (`identify -format '%%w' %%f`) do @set WIDTH=%%i
138
+
139
+
140
+
141
+ REM アドバイスにより追加
142
+
143
+ set HEIGHT=!HEIGHT:'=!
144
+
145
+ set WIDTH=!WIDTH:'=!
146
+
147
+
148
+
149
+ if !HEIGHT! GEQ !WIDTH! (
150
+
151
+ REM 縦幅 >= 横幅
152
+
153
+ convert -resize x900 %%f %%~nf_resized.png
154
+
155
+ ) else (
156
+
157
+ REM 縦幅 < 横幅
158
+
159
+ convert -resize 900x %%f %%~nf_resized.png
160
+
161
+ )
162
+
163
+ )
164
+
165
+ ```

1

タイプミスの修正「縦幅→縦」

2018/03/27 02:03

投稿

ZZ-TOP
ZZ-TOP

スコア36

test CHANGED
File without changes
test CHANGED
@@ -104,13 +104,13 @@
104
104
 
105
105
  if !HEIGHT! GEQ !WIDTH! (
106
106
 
107
- REM 縦 >= 横幅
107
+ REM 縦 >= 横幅
108
108
 
109
109
  convert -resize x900 %%f %%~nf_resized.jpg
110
110
 
111
111
  ) else (
112
112
 
113
- REM 縦 < 横幅
113
+ REM 縦 < 横幅
114
114
 
115
115
  convert -resize 900x %%f %%~nf_resized.jpg
116
116