PictoPy icon indicating copy to clipboard operation
PictoPy copied to clipboard

Feat: Allow users to rename image files

Open codex-yv opened this issue 9 months ago • 3 comments

Describe the feature

Description

I have added a feature that allows users to rename images directly from the App. Users no longer need to navigate to the file path to rename an image.

Current Problem

  • There is no option to rename an image directly within the app.
  • If a user wants to rename an image, they must locate the file path and rename it using the traditional method.

Expected Feature

  • The app should provide an option to rename images internally, so users do not have to worry about file paths or manually opening folders.

Implementation

Backend

  • Added a PUT endpoint: "/rename-image" in backend/app/routes/images.py. It accepts an image ID and a new name, and returns a success status and message.
class RenameImageRequest(BaseModel):
    image_id: str
    rename: str
class RenameImageResponse(BaseModel):
    success: bool
    message: str
  • Used os module to rename the Image file.
folder_path = os.path.dirname(image_path)
extention = os.path.splitext(image_path)[1]
new_file = os.path.join(folder_path, rename+extention)
os.rename(image_path, new_file)
  • The sync microservice automatically updates the database with the new image name.

Frontend

  • Added API endpoint in apiEndpoints.ts and implemented the renameImage function in frontend/src/api/api-functions/images.ts
export const renameImage = async (
  imageId: string,
  newName: string,
): Promise<{ success: boolean; message: string }> => {
  const response = await apiClient.put(imagesEndpoints.renameImage, {
    image_id: imageId,
    rename: newName,
  });
  return response.data;
};
  • Added Rename functionality to MediaInfoPanel.tsx
  • Disabled shortcut keys while renaming an image (e.g., Rotation r, Media Info Panel i, etc.).

Precautions

  • Renaming will fail if the new image name contains unsupported special characters (e.g., *, ^, !, etc.).

Add ScreenShots

Screenshots

Before

https://github.com/user-attachments/assets/c43a38cf-09ca-46c7-b846-19e4d09a23da

After

https://github.com/user-attachments/assets/cb3fffcb-2b9e-43a3-8b69-bb2d25322d55

Record

  • [x] I agree to follow this project's Code of Conduct
  • [x] I want to work on this issue

codex-yv avatar Feb 22 '26 17:02 codex-yv

šŸ‘‹ Thanks for opening this issue! The maintainers will review it shortly. Till then, do not open any PR. This is a strict rule we like to follow around here :)

github-actions[bot] avatar Feb 22 '26 17:02 github-actions[bot]

Hi @rahulharpal1603 sir, would you please assign me this issue?

codex-yv avatar Feb 22 '26 17:02 codex-yv

Hello šŸ‘‹ I am interested in working on this issue. I have basic knowledge of Python and I’m eager to learn and contribute. I will try to provide a clean and well-documented solution. Please assign this issue to me if possible. Thank you 😊

JITENDRAGAHERWAR03 avatar Mar 30 '26 03:03 JITENDRAGAHERWAR03