Throughout this comprehensive tutorial, we will explain how to upload an angular image, show image preview by creating a Base64 url in angular, how to crop an image in angular, how to zoom the image, and how to scale the image in Angular.
At the top of the screen you have a few buttons. Zoom, Rotate, Crop, Delete and drop down for Photo, Document or Whiteboard. In the past, you could click the crop button, crop the image and you are done. In a recent update it appears the Crop button is greyed out unless you select 'Document' in the dropdown. It does not work in 'Photo' mode. Start a 'New App Preview' then open your original project - click in the timeline and select all (cmd + a) - copy that (cmd + C) - go to your empty app preview - click in the timeline and - paste (cmd + V). All your hard work is now in the app preview video. Throughout this comprehensive tutorial, we will explain how to upload an angular image, show image preview by creating a Base64 url in angular, how to crop an image in angular, how to zoom the image, and how to scale the image in Angular. Adding image uploading, previewing, cropping, scaling, and zooming in Angular is easy;.
![App App](https://i.stack.imgur.com/1WuSy.png)
Adding image uploading, previewing, cropping, scaling, and zooming in Angular is easy; this required feature can be created using the ngx-image-cropper plugin.
The Image cropper for Angular is available through the node package manager, and this plugin allows you to add profound features related to an image file.
Register image cropper in Angular’s main app module class, after which you can access numerous methods and API for handling file upload, preview, and zoom. To know more about the image cropper, visit here.
Angular 12 Image Cropper Example
- Step 1: Set Up Angular Environment
- Step 2: Install Bootstrap Package
- Step 3: Add NGX Image Cropper Package
- Step 4: Register ImageCropperModule in App Module
- Step 5: Integrate Image Cropper in Angular
- Step 6: Start Development Server
Set Up Angular Environment
Angular CLI is a go-to tool for angular app development, so execute the command to commence the angular command-line-interface tool installation.
Install a latest version of angular app:
Use command to land on the project’s root:
Install Bootstrap Package
To use the custom UI components, we require to install Bootstrap package in Angular app.
Execute command to install the package:
Include bootstrap css into angular.json file:
Add NGX Image Cropper Package
Once you created a new angular app and entered into the project further, you have to install and add the image cropper plugin into the angular app:
![Preview app crop greyed out youtube Preview app crop greyed out youtube](https://i.stack.imgur.com/djdE9.png)
Register ImageCropperModule in App Module
Ideally, to access the image cropper package’s various methods and properties, you have to register the ImageCropperModule into the main app module class.
Open and insert code into the app.module.ts file:
Integrate Image Cropper in Angular
Implementing image cropper functionality is a facile process; so far, we have completed almost every setup.
Now, get into the TypeScript template import ImageCroppedEvent API; this will allow you to crop an uploaded image. It will convert the image file into Base64 format and show the cropped image preview.
Additionally, we added three custom functions for displaying the cropper component, starting the cropper component and showing an error message when the error occurred while uploading the file.
Add code into the app.component.ts file:
Create button attach change event, similarly use image-cropper directive and load it with various events and methods to configure it for image upload, crop, and preview.
Open and place below code in app.component.html file:
Preview App Crop Greyed Out Photos
Start Development Server
Preview App Crop Greyed Out
Lastly, test the feature we built, so execute the ng serve command from the command prompt to run the development server.
Open the url on the browser:
Conclusion
Preview App Crop Greyed Out For Pc
We have completed the image cropper tutorial; in this example, we learned how to add an image cropper package in angular to upload, preview, crop, zoom, and scale an image that you can directly upload to the server.