@@ -324,15 +324,33 @@ <h2>QSL Card Designer (QSLカードデザイナー)</h2>
324324 img . onload = function ( ) {
325325 const naturalWidth = img . naturalWidth ;
326326 const naturalHeight = img . naturalHeight ;
327-
327+
328+ // まず1900pxの制限を適用(アスペクト比を維持)
329+ const MAX_SIZE = 1900 ;
330+ let scaledWidth = naturalWidth ;
331+ let scaledHeight = naturalHeight ;
332+
333+ if ( naturalWidth > MAX_SIZE || naturalHeight > MAX_SIZE ) {
334+ const aspectRatio = naturalWidth / naturalHeight ;
335+ if ( naturalWidth > naturalHeight ) {
336+ // 横長の場合、幅を1900pxに制限
337+ scaledWidth = MAX_SIZE ;
338+ scaledHeight = MAX_SIZE / aspectRatio ;
339+ } else {
340+ // 縦長の場合、高さを1900pxに制限
341+ scaledHeight = MAX_SIZE ;
342+ scaledWidth = MAX_SIZE * aspectRatio ;
343+ }
344+ }
345+
328346 // 画面サイズを取得(サイドバーとマージンを考慮)
329347 const designerRect = document . querySelector ( '.designer' ) . getBoundingClientRect ( ) ;
330- const maxWidth = Math . min ( naturalWidth , window . innerWidth - designerRect . left - 60 ) ;
331- const maxHeight = Math . min ( naturalHeight , window . innerHeight - designerRect . top - 100 ) ;
332-
348+ const maxWidth = Math . min ( scaledWidth , window . innerWidth - designerRect . left - 60 ) ;
349+ const maxHeight = Math . min ( scaledHeight , window . innerHeight - designerRect . top - 100 ) ;
350+
333351 // アスペクト比を維持しながら画面サイズに収める
334- const aspectRatio = naturalWidth / naturalHeight ;
335- if ( naturalWidth > maxWidth || naturalHeight > maxHeight ) {
352+ const aspectRatio = scaledWidth / scaledHeight ;
353+ if ( scaledWidth > maxWidth || scaledHeight > maxHeight ) {
336354 if ( maxWidth / aspectRatio <= maxHeight ) {
337355 cardWidth = maxWidth ;
338356 cardHeight = maxWidth / aspectRatio ;
@@ -341,8 +359,8 @@ <h2>QSL Card Designer (QSLカードデザイナー)</h2>
341359 cardHeight = maxHeight ;
342360 }
343361 } else {
344- cardWidth = naturalWidth ;
345- cardHeight = naturalHeight ;
362+ cardWidth = scaledWidth ;
363+ cardHeight = scaledHeight ;
346364 }
347365
348366 area . classList . add ( 'has-bg' ) ;
0 commit comments