バージョン選択

フォーラム

メニュー

オンライン状況

42 人のユーザが現在オンラインです。 (32 人のユーザが フォーラム を参照しています。)
登録ユーザ: 0
ゲスト: 42
もっと...

サイト内検索

バグ報告 > フロント機能 > モバイル用イメージの変換に関して

フロント機能

新規スレッドを追加する

スレッド表示 | 古いものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
kishik
投稿日時: 2009/5/18 17:46
対応状況: −−−
仙人
登録日: 2009/4/3
居住地: 東京
投稿: 382
Re: モバイル用イメージの変換に関して
この論理だと(書かれているもの以外はないとして)、
250*50サイズの画像2枚「だけ」を1ページに含む場合、
うまく動作しないのではないでしょうか?
(表示は220で設定されていると仮定しています)
都度対処ですね。

高さ指定された場合も考慮したものを
チケットに登録して、先日ソースに取り込まれたので、
2.4.0からは正しく表示されると思いますよ。


-----
カスタマイズ承ります
http://ec-cube-mall.jp/
http://ec-cube.ec-orange2.jp/
http://wiki.ec-orange2.jp/
QAZU
投稿日時: 2009/5/18 16:07
対応状況: −−−
半人前
登録日: 2007/3/7
居住地:
投稿: 26
Re: モバイル用イメージの変換に関して
kishikさま

プログラマーの方に、kishikさまのソースを渡して、
実際に検証してもらいました。
色々チェックしてもらった結果、下記のようなソースが返ってきました。
検証して、まとめたプログラムだそうです。
現状では、問題なく動いているので、恥ずかしながら、このソース内で行われている処理が個人的に理解できていない状態です・・・

data/include/image_converter.inc
[old]
// 変換後の画像の高さが指定されていない場合、変換後の画像の横幅から求める
if (is_null($this->outputImageHeight)) {
$this->outputImageHeight = $inputImageHeight * ($this->outputImageWidth /
$inputImageWidth);
}

============================================================
[new]

//変換の前画像の横幅が小さい場合画像のサイズそのまま使う
if($inputImageWidth <= $this->outputImageWidth){
$this->outputImageWidth = $inputImageWidth;
$this->outputImageHeight = NULL;
}

// 変換後の画像の高さが指定されていない場合、変換後の画像の横幅から求める
if (is_null($this->outputImageHeight)) {
$this->outputImageHeight = $inputImageHeight * ($this->outputImageWidth /
$inputImageWidth);
}

mobile_image_map_[端末会社].csvによってサイズのsettingになるので
画像のサイズが大きい場合ファイルから呼んで来たサイズと比べて自動計算になるようになっています。
だからサイズが小さなイメージの場合もsettingされたサイズによって自動でイメージ変更になった後高さが計算されるので小さなサイズのイメージが自動変更されて大きくなってしまった現象がありました。

それでsettingされたサイズとイメージサイズを比べた後サイズが小さな場合に$this->outputImageWidthを変更
例えば [$this->outputImageWidth = 220]
1. 250*50 サイズの場合 = > 220*44
if($inputImageWidth <= $this->outputImageWidth){
$this->outputImageWidth = $inputImageWidth;
$this->outputImageHeight = NULL;
}
//(250 <= 220)が違うので$this->outputImageWidth=220になります。

if (is_null($this->outputImageHeight)) {
$this->outputImageHeight = $inputImageHeight * ($this->outputImageWidth /
$inputImageWidth);
}
//$this->outputImageHeight = 50 * (220/250) の計算によって高さが44に変更されます。

2. 100*20 サイズの場合 = > 100*20
if($inputImageWidth <= $this->outputImageWidth){
$this->outputImageWidth = $inputImageWidth;
$this->outputImageHeight = NULL;
}
//(100 <= 220)によって$this->outputImageWidth=100になります。

if (is_null($this->outputImageHeight)) {
$this->outputImageHeight = $inputImageHeight * ($this->outputImageWidth /
$inputImageWidth);
}
//$this->outputImageHeight = 20 * (100/100) の計算によって高さがそのまま20になります。

上のように変更されるので$this->outputImageWidthを変更してくれることだけでも解決可能です。
kishik
投稿日時: 2009/5/13 10:38
対応状況: −−−
仙人
登録日: 2009/4/3
居住地: 東京
投稿: 382
Re: モバイル用イメージの変換に関して
もし不具合がありましたらご連絡ください。
チケットの方にも反映させますので。


-----
カスタマイズ承ります
http://ec-cube-mall.jp/
http://ec-cube.ec-orange2.jp/
http://wiki.ec-orange2.jp/
QAZU
投稿日時: 2009/5/13 10:21
対応状況: −−−
半人前
登録日: 2007/3/7
居住地:
投稿: 26
Re: モバイル用イメージの変換に関して
kishikさま

何度も有難うございます。

早速使わせていただきます。
kishik
投稿日時: 2009/5/12 17:00
対応状況: −−−
仙人
登録日: 2009/4/3
居住地: 東京
投稿: 382
Re: モバイル用イメージの変換に関して
240pxというのはお使いの携帯端末に対応した(最大)画像幅ですね。
EC-CUBEの中に端末ごとのテーブルとして保持されています。
/data/include/mobile_image_map_docomo.csv
などに入っています。
最新の機種などはどれにもマッチせず、
最終行の値が使われます。

ところで、QAZUさんのコードでは
常に320px以下のものは元画像の大きさを使用するようになるので、
コードの後半は全く使われていません。
// 変換後の画像の高さが〜
以下の行は不要なはずです。
そして、
幅320px以上のものを使い始めるとまた不具合が起こります。

私がチケットに書いたものを以下に更新してみてください。


if (is_null($this->outputImageHeight)) {
  $height_was_null = TRUE;
  $this->outputImageHeight = $inputImageHeight * ($this->outputImageWidth / $inputImageWidth);
} else {
  $height_was_null = FALSE;
}
if ($inputImageWidth <= $this->outputImageWidth) {
  if ($inputImageHeight <= $this->outputImageHeight) {
    $this->outputImageWidth  = $inputImageWidth;
    $this->outputImageHeight = $inputImageHeight;
  } else {
    $this->outputImageWidth = $inputImageWidth * ($this->outputImageHeight / $inputImageHeight);
} else {
  if ($inputImageHeight <= $this->outputImageHeight) {
    $this->outputImageHeight = $inputImageHeight * ($this->outputImageWidth / $inputImageWidth);
  } else {
    if ($this->outputImageWidth / $inputImageWidth < $this->outputImageHeight / $inputImageHeight) {
      $this->outputImageHeight = $inputImageHeight * ($this->outputImageWidth / $inputImageWidth);
    } else {
      $this->outputImageWidth = $inputImageWidth * ($this->outputImageHeight / $inputImageHeight);
    }
  }
}


これで意図した動作になるとともに、
将来の変更にも耐えうると思います。


-----
http://ec-cube-mall.jp/
http://ec-cube.ec-orange2.jp/
http://wiki.ec-orange2.jp/
QAZU
投稿日時: 2009/5/12 15:15
対応状況: −−−
半人前
登録日: 2007/3/7
居住地:
投稿: 26
Re: モバイル用イメージの変換に関して
kishikさん

ご回答有難うございます。

チケットに書かれている事をプログラマーの方へ渡して確認しましたところ、縦横比は問題ないのですが、100*20の画像を変換した場合、240*48になってしまうようです。
横幅が240pxに指定されているとか何とか・・・
詳しいことはわからないのですが、実際シミュレーターで見たら、画面いっぱいの幅の画像になっていました。

これは、単純に横幅だけ指定すればいいのかもしれませんが・・・

もしかしたら、こちらに別の原因があるのかも知れませんので、とりあえずご報告まで。

根本的な解決ではないにせよ、とりあえずこちら側のプログラムで縦横のピクセルを指定はせず、問題なく表示できているので現状はそれで走ることにします。
現行の携帯サイトで、幅320px以上の画像を作る事はあまりないと思いますので・・・
kishik
投稿日時: 2009/5/12 13:02
対応状況: −−−
仙人
登録日: 2009/4/3
居住地: 東京
投稿: 382
Re: モバイル用イメージの変換に関して
QAZUさん

その方法だと解決してませんよ。
320より大きい画像を入れてみればわかると思います。
ミソは複数画像があるときに
$this->outputImageHeight
が最初の1回だけNULL判定に引っかかるところなので。


-----
http://ec-cube-mall.jp/
http://ec-cube.ec-orange2.jp/
http://wiki.ec-orange2.jp/
seasoft
投稿日時: 2009/5/12 12:40
対応状況: −−−
登録日: 2008/6/4
居住地:
投稿: 7365
Re: モバイル用イメージの変換に関して
QAZU 様

Width の解決について、非常に良いアイディアだと思います。

ただし、320 で固定するのは微妙な線かもしれません。端末によって、数値が変動しますので。
null チェックの上、$this->outputImageWidth で比較するのが、適切かなと思います。

まぁ、現行端末で考えれば 320 という値は、それなりに適合しているとも考えられますが。


----------------
Seasoft
こちらでの投稿は、アイディア程度に留めさせていただいております。
個別案件の作業は有償で承っております。お気軽にご相談ください。

kishik
投稿日時: 2009/5/12 12:17
対応状況: −−−
仙人
登録日: 2009/4/3
居住地: 東京
投稿: 382
Re: モバイル用イメージの変換に関して
ちょうど同じところを読んでいました。
解決方法をチケットの方にコメントしておきました。

http://svn.ec-cube.net/open_trac/ticket/414


-----
http://ec-cube-mall.jp/
http://ec-cube.ec-orange2.jp/
http://wiki.ec-orange2.jp/
QAZU
投稿日時: 2009/5/12 12:08
対応状況: −−−
半人前
登録日: 2007/3/7
居住地:
投稿: 26
Re: モバイル用イメージの変換に関して
自己解決・・・と言うわけではないですが、
バグの箇所を指摘していただいたので、プログラマーに頼んで確認してもらいました。

一応プログラマーから下記の部分を修正したとレポートが上がってきました。

data/image_converter.inc

[32 Line]
// 変換後の画像の高さが指定されていない場合、変換後の画像の横幅から求める
if (is_null($this->outputImageHeight)) {
$this->outputImageHeight = $inputImageHeight * ($this->outputImageWidth /
$inputImageWidth);
}

==========================

//変換の前画像の横幅が320より小さい場合画像のサイズそのまま使う
if($inputImageWidth <= 320){
$this->outputImageWidth = $inputImageWidth;
$this->outputImageHeight = $inputImageHeight;
}

// 変換後の画像の高さが指定されていない場合、変換後の画像の横幅から求める
if (is_null($this->outputImageHeight)) {
if($inputImageWidth <= 320){
$this->outputImageHeight = $inputImageHeight;
}else{
$this->outputImageHeight = $inputImageHeight * ($this->outputImageWidth
/ $inputImageWidth);
}
}


現在のところ、この修正で無事にイメージの変換ができております。
みなさま、ご協力有難うございました。

ちなみに、この方法が正しいかどうかはわかりません。
(1) 2 3 »
スレッド表示 | 古いものから 前のトピック | 次のトピック | トップ


 



ログイン


EC-CUBE公式 Amazon Payプラグイン

統計情報

総メンバー数は88,286名です
総投稿数は109,688件です

投稿数ランキング

1
seasoft
7365
2
468
3217
3
AMUAMU
2712
4
nanasess
2303
5
umebius
2085
6
yuh
1818
7
h_tanaka
1610
8
red
1567
9
mcontact
1240
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
796
14 ramrun 789
15 karin 689
16 sumida 641
17
homan
633
18 DELIGHT 572
19
patapata
502
20
flealog
485


ネットショップの壺

EC-CUBEインテグレートパートナー

Copyright© EC-CUBE CO.,LTD. All Rights Reserved.