【緊急】月間9500万DLのLiteLLMが乗っ取られた。インストールしただけでSSH鍵・AWS認証・仮想通貨が全部盗まれる #Python - Qiita
https://qiita.com/emi_ndk/items/2332ff5c93e63ab736ad
これ大変そうだよね
これ大変そうだよね
1
4
bash
pip install Pillow
python
from PIL import Image
def convert_to_grayscale(input_path, output_path):
# Open the TIFF image
img = Image.open(input_path)
# Convert the image to grayscale
grayscale_img = img.convert("L")
# Save the grayscale image
grayscale_img.save(output_path, format='TIFF')
if __name__ == "__main__":
# Specify your input and output file paths
input_image_path = "input_image.tiff" # Replace with your input TIFF file
output_image_path = "output_image.tiff" # The output will also be a TIFF file
convert_to_grayscale(input_image_path, output_image_path)
Image class from the Pillow library.convert_to_grayscale() function takes two parameters: the path of the input TIFF image and the path for the output grayscale image.convert("L") function converts the image to grayscale. The mode "L" stands for luminance, which produces a grayscale image."input_image.tiff" with the path to your input TIFF file."output_image.tiff".bash
pip install Pillow
### Step 2: Create a Script to Apply Color Tint
Here's a simple script that opens a #TIFF file, applies a #color tint, and saves the tinted image:python
from PIL import Image
def apply_tint(image_path, output_path, tint_color):
# Open the image
img = Image.open(image_path).convert("RGBA")
# Create a new image for the tints
tinted = Image.new("RGBA", img.size)
# Apply the tint to each pixel
for x in range(img.width):
for y in range(img.height):
r, g, b, a = img.getpixel((x, y))
# Apply tint color
r = int(r * tint_color[0])
g = int(g * tint_color[1])
b = int(b * tint_color[2])
tinted.putpixel((x, y), (r, g, b, a))
# Save the tinted image
tinted.save(output_path, format='TIFF')
if __name__ == "__main__":
# Define the tint color as a tuple (R, G, B) where each value is between 0 and 1
tint_color = (1.0, 0.5, 0.5) # Apply a red tint
apply_tint("input_image.tiff", "output_image.tiff", tint_color)
Image class from the Pillow library.apply_tint() function takes three parameters: the input image path, the output image path, and the tint color."input_image.tiff" with the path to your TIFF file and specify the desired output path in "output_image.tiff". You can adjust tint_color based on the tint effect you want to achieve.tint_color tuple to achieve different tints (e.g., (0.5, 0.5, 1.0) would give a blue tint). Adjustments can also be made based on specific needs, such as different blending modes or efficiencies, especially for larger images.