2

現在、この Paperclip::Processorを使用して、imagemagick の合成コマンドで画像に透かしを入れています。

これにより、事前に作成された単一のファイルを透かしとして挿入できます。これは、公開ファイルに存在します。

ただし、これを変更して、モデル属性を含むウォーターマークを動的に生成できるかどうかを調べています。たとえば、透かしには写真家の名前や、撮影に使用したカメラのモデルが含まれます。

Getty は最近、透かしを変更してこれを実現しました。これは非常に巧妙で、彼らがどのようにそれを行ったかを知りたいと思います。

よろしくお願いします。人々がこれを行う方法を正確に知っているとは思っていませんが、アイデアや一般原則をいただければ幸いです。

4

2 に答える 2

3

はい、Imagemagick で実行できます。私はphpとバッチスクリプトでそれを行いました。ただし、このバッチ スクリプトを ruby​​-on-rails に変換する方法がわかりません。

EXIF データに含まれるほとんどの値を取得し、これと同様のコードで使用できます。

:: Do not display the code while running 
@ECHO OFF 

:: Select the F number from the EXIF data and set the FNumber variable 
FOR /F %%x IN ('identify -ping -format "%%[EXIF:FNumber]" %1') DO SET FNumber=%%x 

:: Set the FNumber1 variable to the F number value 
:: Image Magick returns the F number in the format of 700/100 or 40/10 
FOR /F %%x IN ('convert xc: -ping -format "%%[fx:%FNumber%]" info:') DO SET FNumber1=%%x 

:: Set the value of the shutter variable to the shutter speed 
:: Select the shutter speed from the EXIF data 
:: Image Magick returns the shutter speed in the format of 810/100 
FOR /F %%x IN ('identify -ping -format "%%[EXIF:ShutterSpeedValue]" %1') DO SET shutter=%%x 

:: Format the speed to 8.1 and set the speed variable 
FOR /F %%x IN ('convert xc: -ping -format "%%[fx:%shutter%]" info:') DO SET speed=%%x 

:: Calculate the speed in seconds using the power of 2 
:: and save it in the shutterspeed variable 
FOR /F %%x IN ('convert xc: -ping -format "%%[fx:floor((pow(2,%speed%)))]" info:') ^ 
DO SET shutterspeed=%%x 

:: Add the F number and shutter speed to the image 
:: and save as exif_OriginalImageName 
convert %INPUTFILE% ^ 
-pointsize 16 -fill black -gravity northwest ^ 
-annotate +10+5 "Aperture: F%FNumber1% Shutter speed: 1/%shutterspeed% sec" "%~p1EXIF_%~n1.jpg"  
于 2013-03-01T12:50:05.677 に答える
0

Beerlingtonにご協力いただきありがとうございます。convert_options私は実際に、ペーパークリップのサムネイル処理中に画像に追加することでこれを行う方法を考え出しました。したがって、画像モデルでaは、画像はどこにありますか?

has_attached_file :image, 
    processors: [:thumbnail],
    styles: { 
      wide: {
        geometry: "1120x",
        convert_options: ->(a) { "-quality 92 -font Arial -pointsize 72 -gravity center gradient: -alpha on -channel rgba -fill 'rgba(255,255,255,0.3)' -opaque 'rgba(20,20,20,1)' -draw \"text 0, 340 #{a.picusername}\" -pointsize 30 -draw \"text 0, 390 'license copy here'\"  
      "}
      }

これa.picusernameにより、さまざまな配置とスタイリングの詳細が画像に書き込まれます。これらの詳細については、こちらをご覧ください。

最後の注意-simpleformのようなものを使用して画像モデルに属性を追加する場合、上記の処理手順は、画像自体がデータベースに追加された瞬間に適用されます...したがって、画像の添付に追加されたモデル属性(文字通り、画像添付の下のフォーム入力)はまだ存在しないため、認識されません。

于 2013-03-04T10:02:40.213 に答える