-
Python樹林
[Python] Reading Image Exif Data (Shooting Date, Camera Model, etc.) with Pillow
Photos (JPEG images) taken with smartphones or digital cameras contain Exif (Exchangeable Image File Format) information, which is metadata such as the shooting date, camera model, aperture value, and ISO sensitivity. Using Python's Pill... -
Python樹林
【Python】Pillowで画像のExif情報(撮影日時・カメラモデルなど)を読み込む
スマートフォンやデジタルカメラで撮影した写真(JPEG画像)には、撮影日時、カメラの機種、絞り値、ISO感度などのメタデータである Exif(Exchangeable Image File Format) 情報が含まれています。 PythonのPillowライブラリを使えば、これらの情報を簡... -
Python樹林
[Python] Compositing Images with Pillow: The paste Method and Overlaying Transparent PNGs
Superimposing one image onto another is frequently used for adding copyright notices (watermarks) or synthesizing "SALE" badges onto product images. While you use Pillow's paste() method, specifying the 3rd argument (mask) is essential, ... -
Python樹林
【Python】Pillowで画像を合成する:pasteメソッドと透過PNGの重ね合わせ
画像の上に別の画像を重ねる処理(スーパーインポーズ)は、著作権表示(ウォーターマーク)の追加や、商品画像への「SALE」バッジの合成などで頻繁に使用されます。 Pillowの paste() メソッドを使用しますが、特に背景が透明な画像(PNGなど)をきれいに... -
Python樹林
【Python】Pillowで画像に文字を描画する:日本語フォントの指定と配置
画像処理ライブラリPillowを使用すれば、ベースとなる写真にタイトルや日付を合成し、SNS用のアイキャッチ画像やイベント告知バナーを自動生成することが可能です。 ここでは、「イベント告知用のポスター画像」 を生成するシナリオを例に、日本語フォント... -
Python樹林
[Python] Converting Images to Grayscale with Pillow: Explanation of Color Spaces (Color Modes) and Conversion Methods
When converting color images to black and white (grayscale) or to formats suitable for printing, use the convert() method in Pillow. I will explain the meaning of the "modes (strings)" specified during conversion and the code to actually... -
Python樹林
【Python】Pillowで画像をグレースケール変換する:色空間(カラーモード)の解説と変換メソッド
カラー画像を白黒(グレースケール)に変換したり、印刷用の形式に変換したりする場合、Pillowの convert() メソッドを使用します。 変換の際に指定する「モード(文字列)」の意味と、実際にグレースケール化するコードを解説します。 Pillowにおける主な... -
Python樹林
[Python] Flipping Images with Pillow: Horizontal and Vertical Flip
If you want to create a mirror image or flip an image upside down, use the transpose() method. You control whether it is a "Horizontal Flip" or a "Vertical Flip" by the constant specified in the argument. Executable Sample Code The follo... -
Python樹林
【Python】Pillowで画像を反転させる:左右反転と上下反転
画像の鏡像(ミラーリング)を作りたい場合や、天地を逆にしたい場合は、transpose() メソッドを使用します。 引数に指定する定数によって、「左右反転」か「上下反転」かを制御します。 実行可能なサンプルコード 以下のコードは、画像を読み込み、左右反... -
Python樹林
[Python] Rotating Images with Pillow: The rotate Method and Differences in expand Behavior
Using the rotate() method in the image processing library Pillow (PIL) allows you to rotate images at any angle. The most important setting here is the expand parameter. This value determines whether parts of the image are cropped after ... -
Python樹林
【Python】Pillowで画像を回転させる:rotateメソッドとexpand引数の挙動の違い
画像処理ライブラリPillow (PIL) の rotate() メソッドを使用すると、画像を任意の角度で回転させることができます。 この際、最も重要なのが expand パラメータの設定です。この値によって、回転後に画像の一部が切り取られるか、あるいは画像全体が収ま... -
Python樹林
[Python] Cropping Images with Pillow: The crop Method and Coordinate Rules
When you want to extract only a specific part of an image or remove an unnecessary background (cropping), use the crop() method. The most important part of this method is how to define the four coordinates (tuple) that specify the croppi... -
Python樹林
【Python】Pillowで画像を切り抜く:cropメソッドと座標指定のルール
画像の特定部分だけを抽出したい場合や、不要な背景を除去(クロッピング)したい場合は、crop() メソッドを使用します。 このメソッドで最も重要なのは、切り抜く範囲を指定する 4つの座標(タプル) の定義方法です。ここでは、正しい座標指定のルールと... -
Python樹林
[Python] Resizing Images with Pillow: The Definitive Difference Between resize and thumbnail
There are two main methods to change image size using Pillow: the resize() method and the thumbnail() method. Although they seem similar, their behaviors differ significantly in terms of "whether to maintain the aspect ratio" and "whethe... -
Python樹林
【Python】Pillowで画像をリサイズする:resizeとthumbnailの決定的な違い
Pillowを使って画像のサイズを変更するには、主に resize() メソッドと thumbnail() メソッドの2通りがあります。これらは似ていますが、「アスペクト比(縦横比)を維持するか」 と 「元の画像データを書き換えるか」 という点で挙動が大きく異なります。... -
Python樹林
[Python Pillow] How to Display Processed Images and Save Files
Introduction When performing image processing, displaying the current state on the screen to check it or exporting the final result as a file are fundamental operations. Pillow's Image object provides the show() method, which launches th... -
Python樹林
【Python Pillow】処理した画像の表示確認とファイル保存の方法
画像処理を行う過程で、現在の状態を画面で確認したり、最終的な結果をファイルとして書き出したりする操作は基本となります。 Pillowの Image オブジェクトには、OS標準の画像ビューアを起動して画像を表示させる show() メソッドと、ディスクにファイル... -
Python樹林
[Python] How to Retrieve Image Resolution, Format, and Color Mode with Pillow
Before performing image processing, it is very important to check what characteristics the target image has (whether it is JPEG or PNG, color or black and white, and what the size is). Pillow's Image object has attributes that store this... -
Python樹林
【Python】Pillowで画像の解像度・形式・カラーモードを取得する方法
画像処理を行う前に、対象となる画像がどのような特性(JPEGなのかPNGなのか、カラーなのか白黒なのか、サイズはいくつか)を持っているかを確認することは非常に重要です。 Pillowの Image オブジェクトには、これらの情報を格納した属性が用意されており... -
Python樹林
[Python] Basic Operations of Image Processing Library Pillow (PIL): Resize, Filter, and Save
Introduction When manipulating images programmatically in Python, Pillow (a fork of PIL: Python Imaging Library) is the de facto standard library. It is used in a wide range of applications, such as resizing images during upload in web a... -
Python樹林
【Python】画像処理ライブラリPillow (PIL) の基本操作:リサイズ・フィルタ・保存
Pythonで画像をプログラムから操作する場合、事実上の標準ライブラリとなっているのが Pillow(PIL: Python Imaging Library の派生版)です。 Webアプリケーションでの画像アップロード時のリサイズ処理や、大量の画像のフォーマット一括変換、あるいはAI... -
Python樹林
[Python] Practical Web Scraping: Extracting Information from an E-commerce Product List
The basic flow of "scraping" to collect specific data from web pages involves fetching HTML with requests, parsing the structure with BeautifulSoup, and identifying necessary tags to extract data. Here, we will create code to extract a l... -
Python樹林
【Python】Webスクレイピングの実践:ECサイトの商品一覧から情報を抽出する
Webページから特定のデータを収集する「スクレイピング」の基本フローは、requests でHTMLを取得し、BeautifulSoup で構造解析(パース)を行い、必要なタグを特定してデータを抜き出すという手順になります。 ここでは、スクレイピングの練習用に公開され... -
Python樹林
[Python] Collecting Multiple Elements with BeautifulSoup: Complete Guide to the find_all Method
In web scraping, there are many situations where you want to retrieve multiple elements with the same structure at once, such as a list of news articles or products. While the find() method retrieves only the "first" element, the find_al... -
Python樹林
【Python】BeautifulSoupで要素をまとめて取得する:find_allメソッド完全ガイド
Webスクレイピングでは、ニュース記事の一覧や商品リストなど、同じ構造を持つ複数の要素を一度に取得したい場面が多々あります。 find() メソッドが「最初の1つ」しか取得しないのに対し、find_all() メソッドを使用すると、条件に一致するすべての要素を... -
Python樹林
[Python] Extracting Tag Information with BeautifulSoup: Techniques for Retrieving Text and Attribute Values
After identifying HTML elements (Tag objects) using the find() or find_all() methods, I will explain how to extract the actual necessary data (such as link URLs or displayed text) from them. BeautifulSoup's Tag objects have properties th... -
Python樹林
【Python】BeautifulSoupでタグ情報を取り出す:テキスト・属性値の取得テクニック
find() や find_all() メソッドで HTML 要素(Tag オブジェクト)を特定した後、そこから実際に必要なデータ(リンク先の URL や表示されているテキストなど)を抽出する方法を解説します。 BeautifulSoup の Tag オブジェクトは、Python の辞書(dict)や... -
Python樹林
[Python] Locating Elements with BeautifulSoup: Search Techniques Using Tag Names, IDs, and Class Attributes
In web scraping, mastering the find() method is crucial for accurately extracting only the necessary data from the entire HTML. By combining not just simple tag name searches but also id and class attributes, or by searching further down... -
Python樹林
【Python】BeautifulSoupで要素を特定する:タグ名・ID・クラス属性による検索テクニック
Webスクレイピングにおいて、HTML全体から必要なデータだけを正確に抜き出すためには、find() メソッドの使いこなしが重要です。単純なタグ名の検索だけでなく、id 属性や class 属性を組み合わせたり、取得した要素からさらに階層を下って検索したりする... -
Python樹林
[Python] Parsing HTML with Beautiful Soup 4: Basics of Element Retrieval and Text Extraction
When performing web scraping in Python, the HTML parsing library Beautiful Soup 4 (bs4) is essential. It allows you to search for specific tags (such as <h1> or <p>) within complex HTML structures and extract text or attribut...