BrushCue Example: Add Frame¶
You can use this tool online at https://www.brushcue.com/tools/add-frame
In [ ]:
!pip install brushcue
In [1]:
import brushcue
from PIL import Image
import io
image_input_1 = brushcue.composition_monet_women_with_parasol() # insert your own image here
rgba_color_constant_2 = brushcue.r_g_b_a_color_constant(1, 1, 1, 1)
composition_color_profile_3 = brushcue.composition_color_profile(image_input_1)
vector_2_float_from_components_4 = brushcue.vector2f_from_components(1.0, 1.0)
transform_2d_identity_5 = brushcue.transform2_identity()
frame_width_6 = brushcue.int_passthrough(200)
int_to_float_7 = brushcue.int_to_float(frame_width_6)
int_to_float_8 = brushcue.int_to_float(frame_width_6)
composition_bounds_9 = brushcue.composition_bounds(image_input_1)
int_multiply_10 = brushcue.int_multiply(frame_width_6, 2)
int_multiply_11 = brushcue.int_multiply(frame_width_6, 2)
vector_2_float_from_components_12 = brushcue.vector2f_from_components(int_to_float_7, int_to_float_8)
bounds2f_width_13 = brushcue.bounds2f_width(composition_bounds_9)
bounds2f_height_14 = brushcue.bounds2f_height(composition_bounds_9)
vector_2_int_from_components_15 = brushcue.vector2i_from_components(int_multiply_10, int_multiply_11)
transform_2d_translation_16 = brushcue.transform2_translation(transform_2d_identity_5, vector_2_float_from_components_12)
float_round_to_int_17 = brushcue.float_round_to_int(bounds2f_width_13)
float_round_to_int_18 = brushcue.float_round_to_int(bounds2f_height_14)
transform_2d_scale_19 = brushcue.transform2_scale(transform_2d_translation_16, vector_2_float_from_components_4)
vector_2_int_from_components_20 = brushcue.vector2i_from_components(float_round_to_int_17, float_round_to_int_18)
transform_2d_rotate_21 = brushcue.transform2_rotate(transform_2d_scale_19, 0.0)
vector_2_int_add_22 = brushcue.vector2i_add(vector_2_int_from_components_20, vector_2_int_from_components_15)
background_color_rect_23 = brushcue.composition_color_rect(rgba_color_constant_2, composition_color_profile_3, vector_2_int_add_22)
blend_image_over_background_24 = brushcue.composition_blend_alpha(image_input_1, background_color_rect_23, transform_2d_rotate_21)
ctx = brushcue.Context()
result = blend_image_over_background_24.execute(ctx)
composition = result.as_composition()
data_bytes = composition.to_image_bytes(ctx)
img = Image.open(io.BytesIO(data_bytes))
img.thumbnail((400, 400)) # remove this line for full resolution
img
Out[1]: